去除无效业务类
This commit is contained in:
parent
6770f058d5
commit
14ce522539
@ -1,67 +0,0 @@
|
|||||||
package cn.lili.modules.system.entity.dos;
|
|
||||||
|
|
||||||
|
|
||||||
import cn.lili.mybatis.BaseEntity;
|
|
||||||
import cn.lili.modules.system.entity.vo.InstantDeliveryVO;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 即时配送
|
|
||||||
*
|
|
||||||
* @author pikachu
|
|
||||||
* @since 2020/12/01 15:58
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@TableName("li_instant_delivery")
|
|
||||||
@ApiModel(value = "即时配送")
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class InstantDelivery extends BaseEntity {
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 即时配送名称
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "即时配送名称")
|
|
||||||
private String deliveryName;
|
|
||||||
/**
|
|
||||||
* 是否开启即时配送,1开启,0未开启
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "是否开启即时配送,1开启,0未开启")
|
|
||||||
private Integer deliveryOpen;
|
|
||||||
/**
|
|
||||||
* 即时配送配置
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "即时配送配置")
|
|
||||||
private String deliveryConfig;
|
|
||||||
/**
|
|
||||||
* 即时配送bean
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "即时配送bean")
|
|
||||||
private String deliveryBean;
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "封面图片")
|
|
||||||
private String images;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据vo参数构建do
|
|
||||||
*
|
|
||||||
* @param instantDeliveryVO
|
|
||||||
*/
|
|
||||||
public InstantDelivery(InstantDeliveryVO instantDeliveryVO) {
|
|
||||||
this.setDeliveryName(instantDeliveryVO.getDeliveryName());
|
|
||||||
this.setDeliveryOpen(instantDeliveryVO.getDeliveryOpen());
|
|
||||||
this.setDeliveryBean(instantDeliveryVO.getDeliveryBean());
|
|
||||||
Gson gson = new Gson();
|
|
||||||
this.setDeliveryConfig(gson.toJson(instantDeliveryVO.getConfigItems()));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,99 +0,0 @@
|
|||||||
package cn.lili.modules.system.entity.dos;
|
|
||||||
|
|
||||||
|
|
||||||
import cn.lili.common.utils.StringUtils;
|
|
||||||
import cn.lili.modules.system.entity.plugin.logistics.dada.enums.DadaOrderStatusEnum;
|
|
||||||
import cn.lili.modules.system.entity.plugin.logistics.dada.vo.DdOrderBackVO;
|
|
||||||
import cn.lili.mybatis.BaseIdEntity;
|
|
||||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import org.springframework.data.annotation.CreatedDate;
|
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 即时配送日志
|
|
||||||
*
|
|
||||||
* @author pikachu
|
|
||||||
* @since 2020/12/01 15:58
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@TableName("li_instant_delivery_log")
|
|
||||||
@ApiModel(value = "即时配送日志")
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class InstantDeliveryLog extends BaseIdEntity {
|
|
||||||
|
|
||||||
|
|
||||||
@CreatedDate
|
|
||||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
@TableField(fill = FieldFill.INSERT)
|
|
||||||
@ApiModelProperty(value = "创建时间", hidden = true)
|
|
||||||
private Date createTime;
|
|
||||||
/**
|
|
||||||
* 即时配送订单号
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "即时配送订单号")
|
|
||||||
private String deliveryOrderSn;
|
|
||||||
/**
|
|
||||||
* 商城订单号
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "商城订单号")
|
|
||||||
private String orderSn;
|
|
||||||
/**
|
|
||||||
* 即时配送订单状态
|
|
||||||
*
|
|
||||||
* @see DadaOrderStatusEnum
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "即时配送订单状态")
|
|
||||||
private String deliveryOrderStatus;
|
|
||||||
/**
|
|
||||||
* 配送员ID
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "即时配送骑手编号")
|
|
||||||
private String distributorNumber;
|
|
||||||
/**
|
|
||||||
* 配送员姓名,接单以后会存储
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "配送员姓名,接单以后会存储")
|
|
||||||
private String distributorName;
|
|
||||||
/**
|
|
||||||
* 配送员手机号,接单以后存储
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "配送员手机号,接单以后存储")
|
|
||||||
private String distributorMobile;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 订单取消原因,其他状态下默认值为空字符串
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "订单取消原因,其他状态下默认值为空字符串")
|
|
||||||
private String cancelReason;
|
|
||||||
|
|
||||||
public InstantDeliveryLog(DdOrderBackVO ddOrderBackVO) {
|
|
||||||
this.setCancelReason(ddOrderBackVO.getCancelReason());
|
|
||||||
this.setOrderSn(ddOrderBackVO.getOrderId());
|
|
||||||
this.setDeliveryOrderSn(ddOrderBackVO.getClientId());
|
|
||||||
if (!StringUtils.isEmpty(ddOrderBackVO.getDmMobile())) {
|
|
||||||
this.setDistributorMobile(ddOrderBackVO.getDmMobile());
|
|
||||||
}
|
|
||||||
if (!StringUtils.isEmpty(ddOrderBackVO.getDmName())) {
|
|
||||||
this.setDistributorName(ddOrderBackVO.getDmName());
|
|
||||||
}
|
|
||||||
if (ddOrderBackVO.getDmId() != null) {
|
|
||||||
this.setDistributorNumber(ddOrderBackVO.getDmId().toString());
|
|
||||||
}
|
|
||||||
this.setDeliveryOrderStatus(DadaOrderStatusEnum.getText(100));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,63 +0,0 @@
|
|||||||
package cn.lili.modules.system.entity.enums;
|
|
||||||
|
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 即时配送url接口地址
|
|
||||||
*
|
|
||||||
* @author pikachu
|
|
||||||
* @since 2020/9/11 17:03
|
|
||||||
*/
|
|
||||||
public enum InstantDeliveryUrl {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 订单推送
|
|
||||||
*/
|
|
||||||
DD_ADD_ORDER("/api/order/addOrder"),
|
|
||||||
/**
|
|
||||||
* 订单重发
|
|
||||||
*/
|
|
||||||
DD_RE_ADD_ORDER("/api/order/reAddOrder"),
|
|
||||||
/**
|
|
||||||
* 订单妥投异常后,商家确认收货
|
|
||||||
*/
|
|
||||||
DD_CONFIRM_ORDER("/api/order/confirm/goods"),
|
|
||||||
/**
|
|
||||||
* 店铺添加
|
|
||||||
*/
|
|
||||||
DD_ADD_SHOP("/api/store/add"),
|
|
||||||
/**
|
|
||||||
* 店铺修改
|
|
||||||
*/
|
|
||||||
DD_UPDATE_SHOP("/api/store/update"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 订单详细信息
|
|
||||||
*/
|
|
||||||
DD_QUERY_ORDER("/api/order/status/query"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 订单取消
|
|
||||||
*/
|
|
||||||
DD_CANDLE_ORDER("/api/order/formalCancel"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 城市code获取
|
|
||||||
*/
|
|
||||||
DD_CITY_CODE("/api/cityCode/list");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 类型
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private final String url;
|
|
||||||
|
|
||||||
InstantDeliveryUrl(String url) {
|
|
||||||
this.url = url;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -1,40 +0,0 @@
|
|||||||
package cn.lili.modules.system.entity.plugin;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 插件配置类
|
|
||||||
*
|
|
||||||
* @author pikachu
|
|
||||||
* @version v4.0
|
|
||||||
* @since 2020/12/01 15:58
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@ToString
|
|
||||||
public class ConfigItem {
|
|
||||||
/**
|
|
||||||
* 配置文件name值
|
|
||||||
*/
|
|
||||||
private String name;
|
|
||||||
/**
|
|
||||||
* 配置文件name映射文本值
|
|
||||||
*/
|
|
||||||
private String text;
|
|
||||||
/**
|
|
||||||
* 配置文件显示在浏览器时,input的type属性
|
|
||||||
*/
|
|
||||||
private String type;
|
|
||||||
/**
|
|
||||||
* 配置的值
|
|
||||||
*/
|
|
||||||
private Object value;
|
|
||||||
/**
|
|
||||||
* 如果是select 是需要将可选项传递到前台
|
|
||||||
*/
|
|
||||||
private List<RadioOption> options;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,28 +0,0 @@
|
|||||||
package cn.lili.modules.system.entity.plugin;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 单选配置类
|
|
||||||
*
|
|
||||||
* @author pikachu
|
|
||||||
* @version v4.0
|
|
||||||
* @Description:单选配置类
|
|
||||||
* @since 2020/12/01 15:58
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@ToString
|
|
||||||
public class RadioOption {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 选项
|
|
||||||
*/
|
|
||||||
private String label;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 选项值
|
|
||||||
*/
|
|
||||||
private Object value;
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,119 +0,0 @@
|
|||||||
package cn.lili.modules.system.entity.plugin.logistics;
|
|
||||||
|
|
||||||
import cn.lili.modules.member.entity.dos.MemberAddress;
|
|
||||||
import cn.lili.modules.order.order.entity.dos.Order;
|
|
||||||
import cn.lili.modules.store.entity.vos.StoreDetailVO;
|
|
||||||
import cn.lili.modules.system.entity.plugin.ConfigItem;
|
|
||||||
import cn.lili.modules.system.entity.vo.InstantDeliveryResultVO;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 即时配送插件方法
|
|
||||||
*
|
|
||||||
* @author pikachu
|
|
||||||
* @version v1.0
|
|
||||||
* @since 2020/12/01 15:58
|
|
||||||
*/
|
|
||||||
public interface InstantDeliveryPlugin {
|
|
||||||
/**
|
|
||||||
* 获取即时配送的插件ID
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
String getPluginId();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取即时配送的插件名称
|
|
||||||
*
|
|
||||||
* @return 插件名称
|
|
||||||
*/
|
|
||||||
String getPluginName();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 即时配送是否开启
|
|
||||||
*
|
|
||||||
* @return 0 不开启 1 开启
|
|
||||||
*/
|
|
||||||
Integer getOpen();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取取消原因id
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Integer cancelReasonId();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 配置各个即时配送的参数
|
|
||||||
*
|
|
||||||
* @return 在页面加载的即时配送参数
|
|
||||||
*/
|
|
||||||
List<ConfigItem> getDefaultConfigItem();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 同城配送新建店铺
|
|
||||||
*
|
|
||||||
* @param storeDetailVO 店铺信息
|
|
||||||
* @param config 配送参数
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
InstantDeliveryResultVO addStore(StoreDetailVO storeDetailVO, Map config);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 同城配送新建店铺
|
|
||||||
*
|
|
||||||
* @param storeDetailVO 店铺信息
|
|
||||||
* @param config 配送参数
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
InstantDeliveryResultVO editStore(StoreDetailVO storeDetailVO, Map config);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询订单详细
|
|
||||||
*
|
|
||||||
* @param orderSn 传递到达达的订单sn,目前使用的是商城订单sn传递的所有只需要传递商城sn就可以
|
|
||||||
* @param config 配置参数
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
InstantDeliveryResultVO getOrderDetail(String orderSn, Map config);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 妥投异常之物品返回完成
|
|
||||||
*
|
|
||||||
* @param orderSn 传递到达达的订单sn,目前使用的是商城订单sn传递的所有只需要传递商城sn就可以
|
|
||||||
* @param config 配置参数
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
InstantDeliveryResultVO orderConfirm(String orderSn, Map config);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 妥投异常之物品返回完成
|
|
||||||
*
|
|
||||||
* @param orderSn 传递到达达的订单sn,目前使用的是商城订单sn传递的所有只需要传递商城sn就可以
|
|
||||||
* @param cancelReason 取消原因
|
|
||||||
* @param config 配置参数
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
InstantDeliveryResultVO orderCandle(String orderSn, String cancelReason, Map config);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 发送同城配送订单
|
|
||||||
*
|
|
||||||
* @param order 订单
|
|
||||||
* @param memberAddress 会员地址
|
|
||||||
* @param type 类型
|
|
||||||
* @param config 配置
|
|
||||||
* @param storeDetailVO 店铺详情VO
|
|
||||||
* @return 配送订单返回
|
|
||||||
*/
|
|
||||||
InstantDeliveryResultVO sendReOrder(Order order, StoreDetailVO storeDetailVO, MemberAddress memberAddress, Integer type, Map config);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 即时配送回调
|
|
||||||
*
|
|
||||||
* @param object 因为不同配送的返回对象不同,所以需要obj 去传递参数,在不同的插件中转换
|
|
||||||
*/
|
|
||||||
void callBack(Object object);
|
|
||||||
}
|
|
||||||
@ -1,346 +0,0 @@
|
|||||||
package cn.lili.modules.system.entity.plugin.logistics.dada;
|
|
||||||
|
|
||||||
import cn.hutool.json.JSONArray;
|
|
||||||
import cn.hutool.json.JSONObject;
|
|
||||||
import cn.hutool.json.JSONUtil;
|
|
||||||
import cn.lili.common.utils.DateUtil;
|
|
||||||
import cn.lili.common.utils.StringUtils;
|
|
||||||
import cn.lili.modules.member.entity.dos.MemberAddress;
|
|
||||||
import cn.lili.modules.order.order.entity.dos.Order;
|
|
||||||
import cn.lili.modules.store.entity.enums.StoreStatusEnum;
|
|
||||||
import cn.lili.modules.store.entity.vos.StoreDetailVO;
|
|
||||||
import cn.lili.modules.store.service.StoreDetailService;
|
|
||||||
import cn.lili.modules.system.entity.dos.InstantDeliveryLog;
|
|
||||||
import cn.lili.modules.system.entity.enums.InstantDeliveryUrl;
|
|
||||||
import cn.lili.modules.system.entity.plugin.ConfigItem;
|
|
||||||
import cn.lili.modules.system.entity.plugin.logistics.InstantDeliveryPlugin;
|
|
||||||
import cn.lili.modules.system.entity.plugin.logistics.dada.vo.DdOrderBackVO;
|
|
||||||
import cn.lili.modules.system.entity.vo.CityResult;
|
|
||||||
import cn.lili.modules.system.entity.vo.InstantDeliveryResultVO;
|
|
||||||
import cn.lili.modules.system.service.InstantDeliveryLogService;
|
|
||||||
import cn.lili.modules.system.utils.HttpUtils;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 达达同城配送
|
|
||||||
*
|
|
||||||
* @author pikachu
|
|
||||||
* @version v4.0
|
|
||||||
* @since 2020/12/01 15:58
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@Component("ddPlugin")
|
|
||||||
public class DadaPlugin implements InstantDeliveryPlugin {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private StoreDetailService storeDetailService;
|
|
||||||
@Autowired
|
|
||||||
private InstantDeliveryLogService instantDeliveryLogService;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPluginId() {
|
|
||||||
return "ddPlugin";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPluginName() {
|
|
||||||
return "达达";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer getOpen() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ConfigItem> getDefaultConfigItem() {
|
|
||||||
List<ConfigItem> list = new ArrayList();
|
|
||||||
|
|
||||||
ConfigItem url = new ConfigItem();
|
|
||||||
url.setType("text");
|
|
||||||
url.setName("url");
|
|
||||||
url.setText("调用地址");
|
|
||||||
|
|
||||||
|
|
||||||
ConfigItem appKey = new ConfigItem();
|
|
||||||
appKey.setType("text");
|
|
||||||
appKey.setName("app_key");
|
|
||||||
appKey.setText("app_key");
|
|
||||||
|
|
||||||
ConfigItem appSecret = new ConfigItem();
|
|
||||||
appSecret.setType("text");
|
|
||||||
appSecret.setName("app_secret");
|
|
||||||
appSecret.setText("app_secret");
|
|
||||||
|
|
||||||
ConfigItem merchantsId = new ConfigItem();
|
|
||||||
merchantsId.setType("text");
|
|
||||||
merchantsId.setName("merchants_id");
|
|
||||||
merchantsId.setText("商户Id");
|
|
||||||
list.add(url);
|
|
||||||
list.add(appKey);
|
|
||||||
list.add(appSecret);
|
|
||||||
list.add(merchantsId);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public InstantDeliveryResultVO addStore(StoreDetailVO storeDetailVO, Map config) {
|
|
||||||
JSONArray jsonArray = new JSONArray();
|
|
||||||
JSONObject jsonObject = new JSONObject();
|
|
||||||
//业务类型(食品小吃-1,饮料-2,鲜花-3,文印票务-8,便利店-9,水果生鲜-13,同城电商-19, 医药-20,蛋糕-21,酒品-24,小商品市场-25,服装-26,汽修零配-27,数码-28,小龙虾-29,火锅-51,其他-5)
|
|
||||||
jsonObject.set("business", 19);
|
|
||||||
//门店地址
|
|
||||||
jsonObject.set("station_address", storeDetailVO.getCompanyAddress());
|
|
||||||
//联系人姓名
|
|
||||||
jsonObject.set("contact_name", storeDetailVO.getLinkName());
|
|
||||||
//联系人电话
|
|
||||||
jsonObject.set("phone", storeDetailVO.getLinkPhone());
|
|
||||||
//达达商家app账号
|
|
||||||
jsonObject.set("username", storeDetailVO.getLinkPhone());
|
|
||||||
//达达商家app密码
|
|
||||||
jsonObject.set("password", "a" + storeDetailVO.getLinkPhone());
|
|
||||||
jsonArray.add(jsonObject);
|
|
||||||
//发送请求的url
|
|
||||||
String url = StringUtils.toString(config.get("url"));
|
|
||||||
Map<String, String> requestJson = getConfig(config, jsonArray.toString());
|
|
||||||
String result = HttpUtils.doPostWithJson(url + InstantDeliveryUrl.DD_ADD_SHOP.getUrl(), requestJson);
|
|
||||||
//组织返回参数
|
|
||||||
InstantDeliveryResultVO instantDeliveryResultVO = JSONUtil.toBean(result, InstantDeliveryResultVO.class);
|
|
||||||
Map<String, List> map = (Map<String, List>) instantDeliveryResultVO.getResult();
|
|
||||||
List<Map<String, Object>> successList = map.get("successList");
|
|
||||||
if (successList.size() > 0) {
|
|
||||||
for (Map<String, Object> obj : successList) {
|
|
||||||
//如果成功调用店铺修改 将门店编码写入数据库
|
|
||||||
UpdateWrapper updateWrapper = new UpdateWrapper();
|
|
||||||
updateWrapper.in("id", storeDetailVO.getStoreId());
|
|
||||||
updateWrapper.set("dd_code", obj.get("originStoreId").toString());
|
|
||||||
storeDetailService.update(updateWrapper);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
List<Map<String, Object>> errorList = map.get("failedList");
|
|
||||||
if (errorList != null && errorList.size() > 0) {
|
|
||||||
for (Map<String, Object> obj : errorList) {
|
|
||||||
throw new RuntimeException(obj.get("msg").toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return instantDeliveryResultVO;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public InstantDeliveryResultVO editStore(StoreDetailVO storeDetailVO, Map config) {
|
|
||||||
//如果达达code没有则不进行修改
|
|
||||||
if (StringUtils.isEmpty(storeDetailVO.getDdCode())) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
JSONObject jsonObject = new JSONObject();
|
|
||||||
//门店编号
|
|
||||||
jsonObject.set("origin_store_id", storeDetailVO.getDdCode());
|
|
||||||
//门店名称
|
|
||||||
// jsonObject.put("station_name", storeDetailVO.getStoreName());
|
|
||||||
//业务类型(食品小吃-1,饮料-2,鲜花-3,文印票务-8,便利店-9,水果生鲜-13,同城电商-19, 医药-20,蛋糕-21,酒品-24,小商品市场-25,服装-26,汽修零配-27,数码-28,小龙虾-29,火锅-51,其他-5)
|
|
||||||
jsonObject.set("business", 19);
|
|
||||||
//城市名称(如,上海)
|
|
||||||
// jsonObject.put("city_name", storeDetailVO.getCompanyCity());
|
|
||||||
//区域名称(如,浦东新区)
|
|
||||||
// jsonObject.put("area_name", storeDetailVO.getCompanyCounty());
|
|
||||||
//门店地址
|
|
||||||
jsonObject.set("station_address", storeDetailVO.getCompanyAddress());
|
|
||||||
// //门店经度
|
|
||||||
// jsonObject.put("lng", storeDetailVO.getStoreLongitude());
|
|
||||||
// //门店纬度
|
|
||||||
// jsonObject.put("lat", storeDetailVO.getStoreLatitude());
|
|
||||||
//联系人姓名
|
|
||||||
jsonObject.set("contact_name", storeDetailVO.getLinkName());
|
|
||||||
//联系人电话
|
|
||||||
jsonObject.set("phone", storeDetailVO.getLinkPhone());
|
|
||||||
if (storeDetailVO.getStoreDisable().equals(StoreStatusEnum.OPEN.value())) {
|
|
||||||
jsonObject.set("status", 1);
|
|
||||||
} else {
|
|
||||||
jsonObject.set("status", 0);
|
|
||||||
}
|
|
||||||
//发送请求的url
|
|
||||||
String url = StringUtils.toString(config.get("url"));
|
|
||||||
Map<String, String> requestJson = getConfig(config, jsonObject.toString());
|
|
||||||
String result = HttpUtils.doPostWithJson(url + InstantDeliveryUrl.DD_UPDATE_SHOP.getUrl(), requestJson);
|
|
||||||
//组织返回参数
|
|
||||||
InstantDeliveryResultVO instantDeliveryResultVO = JSONUtil.toBean(result, InstantDeliveryResultVO.class);
|
|
||||||
if ("fail".equals(instantDeliveryResultVO.getStatus())) {
|
|
||||||
log.error("达达店铺信息修改失败",instantDeliveryResultVO.getMsg());
|
|
||||||
}
|
|
||||||
return instantDeliveryResultVO;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public InstantDeliveryResultVO getOrderDetail(String orderSn, Map config) {
|
|
||||||
JSONObject jsonObject = new JSONObject();
|
|
||||||
jsonObject.set("order_id", orderSn);
|
|
||||||
//发送请求的url
|
|
||||||
String url = StringUtils.toString(config.get("url"));
|
|
||||||
Map<String, String> requestJson = getConfig(config, jsonObject.toString());
|
|
||||||
String result = HttpUtils.doPostWithJson(url + InstantDeliveryUrl.DD_QUERY_ORDER.getUrl(), requestJson);
|
|
||||||
//组织返回参数
|
|
||||||
InstantDeliveryResultVO instantDeliveryResultVO = JSONUtil.toBean(result, InstantDeliveryResultVO.class);
|
|
||||||
return instantDeliveryResultVO;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public InstantDeliveryResultVO orderConfirm(String orderSn, Map config) {
|
|
||||||
JSONObject jsonObject = new JSONObject();
|
|
||||||
jsonObject.set("order_id", orderSn);
|
|
||||||
//发送请求的url
|
|
||||||
String url = StringUtils.toString(config.get("url"));
|
|
||||||
Map<String, String> requstJson = getConfig(config, jsonObject.toString());
|
|
||||||
String result = HttpUtils.doPostWithJson(url + InstantDeliveryUrl.DD_CONFIRM_ORDER.getUrl(), requstJson);
|
|
||||||
//组织返回参数
|
|
||||||
InstantDeliveryResultVO instantDeliveryResultVO = JSONUtil.toBean(result, InstantDeliveryResultVO.class);
|
|
||||||
return instantDeliveryResultVO;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public InstantDeliveryResultVO orderCandle(String orderSn, String cancelReason, Map config) {
|
|
||||||
JSONObject jsonObject = new JSONObject();
|
|
||||||
jsonObject.set("order_id", orderSn);
|
|
||||||
jsonObject.set("cancel_reason_id", this.cancelReasonId());
|
|
||||||
jsonObject.set("cancel_reason", cancelReason);
|
|
||||||
//发送请求的url
|
|
||||||
String url = StringUtils.toString(config.get("url"));
|
|
||||||
Map<String, String> requstJson = getConfig(config, jsonObject.toString());
|
|
||||||
String result = HttpUtils.doPostWithJson(url + InstantDeliveryUrl.DD_CANDLE_ORDER.getUrl(), requstJson);
|
|
||||||
//组织返回参数
|
|
||||||
InstantDeliveryResultVO instantDeliveryResultVO = JSONUtil.toBean(result, InstantDeliveryResultVO.class);
|
|
||||||
return instantDeliveryResultVO;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public InstantDeliveryResultVO sendReOrder(Order order, StoreDetailVO storeDetailVO, MemberAddress memberAddress, Integer type, Map config) {
|
|
||||||
JSONObject jsonObject = new JSONObject();
|
|
||||||
//门店编号,门店创建后可在门店列表和单页查看
|
|
||||||
jsonObject.set("store_no", storeDetailVO.getDdCode());
|
|
||||||
//第三方订单ID
|
|
||||||
jsonObject.set("origin_id", order.getSn());
|
|
||||||
//订单所在城市的code http://newopen.imdada.cn/#/development/file/cityList?_k=l76a7s
|
|
||||||
String city = memberAddress.getConsigneeAddressPath().substring(memberAddress.getConsigneeAddressPath().indexOf(",") + 1, memberAddress.getConsigneeAddressPath().indexOf(",", memberAddress.getConsigneeAddressPath().indexOf(",") + 1));
|
|
||||||
jsonObject.set("city_code", this.getCityCode(city, config));
|
|
||||||
//订单金额
|
|
||||||
jsonObject.set("cargo_price", order.getFlowPrice());
|
|
||||||
//是否需要垫付 1:是 0:否 (垫付订单金额,非运费)
|
|
||||||
jsonObject.set("is_prepay", 0);
|
|
||||||
//收货人姓名
|
|
||||||
jsonObject.set("receiver_name", memberAddress.getName());
|
|
||||||
//收货人地址
|
|
||||||
jsonObject.set("receiver_address", memberAddress.getDetail());
|
|
||||||
//收货人地址纬度(高德坐标系,若是其他地图经纬度需要转化成高德地图经纬度
|
|
||||||
jsonObject.set("receiver_lat", memberAddress.getLat());
|
|
||||||
//收货人地址经度(高德坐标系,若是其他地图经纬度需要转化成高德地图经纬度
|
|
||||||
jsonObject.set("receiver_lng", memberAddress.getLat());
|
|
||||||
//回调URL
|
|
||||||
//jsonObject.put("callback", domainHelper.getCallback() + "/trade/delivery/order/call-back");
|
|
||||||
//收货人手机号(手机号和座机号必填一项)
|
|
||||||
jsonObject.set("receiver_phone", memberAddress.getMobile());
|
|
||||||
//是否使用保价费(0:不使用保价,1:使用保价; 同时,请确保填写了订单金额(cargo_price))
|
|
||||||
jsonObject.set("is_use_insurance", 0);
|
|
||||||
//订单重量(单位:Kg)
|
|
||||||
jsonObject.set("cargo_weight", order.getWeight());
|
|
||||||
Map<String, String> requstJson = getConfig(config, jsonObject.toString());
|
|
||||||
//发送请求的url
|
|
||||||
String url = StringUtils.toString(config.get("url"));
|
|
||||||
String result = null;
|
|
||||||
if (type == 0) {
|
|
||||||
result = HttpUtils.doPostWithJson(url + InstantDeliveryUrl.DD_ADD_ORDER.getUrl(), requstJson);
|
|
||||||
} else {
|
|
||||||
result = HttpUtils.doPostWithJson(url + InstantDeliveryUrl.DD_RE_ADD_ORDER.getUrl(), requstJson);
|
|
||||||
}
|
|
||||||
InstantDeliveryResultVO instantDeliveryResultVO = JSONUtil.toBean(result, InstantDeliveryResultVO.class);
|
|
||||||
if ("fail".equals(instantDeliveryResultVO.getStatus())) {
|
|
||||||
log.error("达达订单发送失败,订单号为",order.getSn() + "," + instantDeliveryResultVO.getMsg());
|
|
||||||
//如果发送失败择等待一秒重新发送,如果失败择记录日志
|
|
||||||
try {
|
|
||||||
Thread.sleep(1000);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("达达订单发布失败",e);
|
|
||||||
}
|
|
||||||
result = HttpUtils.doPostWithJson(url + InstantDeliveryUrl.DD_RE_ADD_ORDER.getUrl(), requstJson);
|
|
||||||
InstantDeliveryResultVO instantDeliveryResResultVO = JSONUtil.toBean(result, InstantDeliveryResultVO.class);
|
|
||||||
if ("fail".equals(instantDeliveryResResultVO.getStatus())) {
|
|
||||||
log.error("达达订单重试发送失败,订单号为" + order.getSn() + "," + instantDeliveryResultVO.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return instantDeliveryResultVO;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer cancelReasonId() {
|
|
||||||
return 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 达达配送统一参数整合
|
|
||||||
*
|
|
||||||
* @param config
|
|
||||||
* @param json
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, String> getConfig(Map config, String json) {
|
|
||||||
//组织参数
|
|
||||||
String appKey = StringUtils.toString(config.get("app_key"));
|
|
||||||
String appSecret = StringUtils.toString(config.get("app_secret"));
|
|
||||||
String merchantsId = StringUtils.toString(config.get("merchants_id"));
|
|
||||||
//签名发送请求
|
|
||||||
String mysing = appSecret + "app_key" + appKey + "body" + json + "formatjsonsource_id" + merchantsId + "timestamp" + DateUtil.getDateline() + "v1.0" + appSecret;
|
|
||||||
String signature = StringUtils.md5(mysing).toUpperCase();
|
|
||||||
Map<String, String> requstJson = new HashMap<>(8);
|
|
||||||
requstJson.put("source_id", merchantsId);
|
|
||||||
requstJson.put("app_key", appKey);
|
|
||||||
requstJson.put("format", "json");
|
|
||||||
requstJson.put("timestamp", StringUtils.toString(DateUtil.getDateline()));
|
|
||||||
requstJson.put("signature", signature);
|
|
||||||
requstJson.put("body", json);
|
|
||||||
requstJson.put("v", "1.0");
|
|
||||||
return requstJson;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取城市code
|
|
||||||
*
|
|
||||||
* @param cityName 城市名称
|
|
||||||
* @return 城市编码
|
|
||||||
*/
|
|
||||||
private String getCityCode(String cityName, Map config) {
|
|
||||||
//获取参数
|
|
||||||
String url = StringUtils.toString(config.get("url"));
|
|
||||||
JSONObject jsonObject = new JSONObject();
|
|
||||||
Map<String, String> requstJson = getConfig(config, jsonObject.toString());
|
|
||||||
//获取所有城市编码
|
|
||||||
String result = HttpUtils.doPostWithJson(url + InstantDeliveryUrl.DD_CITY_CODE.getUrl(), requstJson);
|
|
||||||
InstantDeliveryResultVO resultDO = JSONUtil.toBean(result, InstantDeliveryResultVO.class);
|
|
||||||
//对数据进行格式化
|
|
||||||
|
|
||||||
List<CityResult> list = JSONUtil.toList(JSONUtil.parseArray(resultDO.getResult()), CityResult.class);
|
|
||||||
for (CityResult cityResult : list) {
|
|
||||||
if (cityName.contains(cityResult.getCityName())) {
|
|
||||||
return cityResult.getCityCode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//如果找不到默认哈尔滨
|
|
||||||
return "0451";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void callBack(Object object) {
|
|
||||||
//强制将obj转换成达达对应的参数对象
|
|
||||||
DdOrderBackVO ddOrderBackVO = (DdOrderBackVO) object;
|
|
||||||
//数据类型转换
|
|
||||||
InstantDeliveryLog instantDeliveryLog = new InstantDeliveryLog(ddOrderBackVO);
|
|
||||||
//保存数据
|
|
||||||
instantDeliveryLogService.save(instantDeliveryLog);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,68 +0,0 @@
|
|||||||
package cn.lili.modules.system.entity.plugin.logistics.dada.enums;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 达达配送订单状态
|
|
||||||
*
|
|
||||||
* @author pikachu
|
|
||||||
*/
|
|
||||||
public enum DadaOrderStatusEnum {
|
|
||||||
//待接单
|
|
||||||
WAIT_RECEIVING(1, "待接单"),
|
|
||||||
//待取货
|
|
||||||
WAIT_PICK_UP(2, "待取货"),
|
|
||||||
//配送中
|
|
||||||
DELIVERY_IN_PROGRESS(3, "配送中"),
|
|
||||||
//已完成
|
|
||||||
COMPLETED(4, "已完成"),
|
|
||||||
//已取消
|
|
||||||
CANCELLED(5, "已取消"),
|
|
||||||
//派单中
|
|
||||||
DISTRIBUTION_LEAFLETS(8, "派单中"),
|
|
||||||
//妥投异常之物品返回中
|
|
||||||
ABNORMAL_BACK(9, "妥投异常之物品返回中"),
|
|
||||||
//妥投异常之物品返回完成
|
|
||||||
ABNORMAL_COMPLETED(10, "妥投异常之物品返回完成"),
|
|
||||||
//骑士到店
|
|
||||||
TO_IN_STORE(100, "骑士到店");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 状态
|
|
||||||
*/
|
|
||||||
@Setter
|
|
||||||
@Getter
|
|
||||||
private Integer status;
|
|
||||||
/**
|
|
||||||
* 状态文本
|
|
||||||
*/
|
|
||||||
@Setter
|
|
||||||
@Getter
|
|
||||||
private String text;
|
|
||||||
|
|
||||||
|
|
||||||
DadaOrderStatusEnum(Integer status, String text) {
|
|
||||||
this.status = status;
|
|
||||||
this.text = text;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取配送模版
|
|
||||||
* @param status 状态
|
|
||||||
* @return 配送模板
|
|
||||||
*/
|
|
||||||
public static String getText(Integer status) {
|
|
||||||
//如果空,则直接返回
|
|
||||||
if (status == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
//对状态枚举值进行处理
|
|
||||||
for (DadaOrderStatusEnum dadaOrderStatusEnum : DadaOrderStatusEnum.values()) {
|
|
||||||
if (status.equals(dadaOrderStatusEnum.getStatus())) {
|
|
||||||
return dadaOrderStatusEnum.getText();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return WAIT_RECEIVING.getText();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,50 +0,0 @@
|
|||||||
package cn.lili.modules.system.entity.plugin.logistics.dada.vo;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
|
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonNaming;
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author 86133
|
|
||||||
* @description: pikachu
|
|
||||||
* @since 2020/9/1215:35
|
|
||||||
*/
|
|
||||||
@ApiModel(description = "达达订单回调参数")
|
|
||||||
@Data
|
|
||||||
@ToString
|
|
||||||
@JsonNaming(value = PropertyNamingStrategy.SnakeCaseStrategy.class)
|
|
||||||
public class DdOrderBackVO {
|
|
||||||
@ApiModelProperty(value = "达达运单号", required = false)
|
|
||||||
private String clientId;
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "交易编号", required = true)
|
|
||||||
private String orderId;
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "订单状态 待接单=1,待取货=2,配送中=3,已完成=4,已取消=5, 指派单=8,妥投异常之物品返回中=9, 妥投异常之物品返回完成=10, 骑士到店=100,创建达达运单失败=1000", required = true)
|
|
||||||
private Integer orderStatus;
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "订单取消原因,其他状态下默认值为空字符串", required = true)
|
|
||||||
private String cancelReason;
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "订单取消原因来源(1:达达配送员取消;2:商家主动取消;3:系统或客服取消;0:默认值)", required = true)
|
|
||||||
private Integer cancelFrom;
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "更新时间", required = true)
|
|
||||||
private Long updateTime;
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "加密串", required = true)
|
|
||||||
private String signature;
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "达达配送员id,接单以后会传", required = false)
|
|
||||||
private Integer dmId;
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "配送员姓名,接单以后会传", required = false)
|
|
||||||
private String dmName;
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "配送员手机号,接单以后会传", required = false)
|
|
||||||
private String dmMobile;
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,24 +0,0 @@
|
|||||||
package cn.lili.modules.system.entity.vo;
|
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 达达返回值
|
|
||||||
*
|
|
||||||
* @author Chopper
|
|
||||||
* @since 2020/9/12 14:05
|
|
||||||
*/
|
|
||||||
@ApiModel
|
|
||||||
@Data
|
|
||||||
public class InstantDeliveryResultVO {
|
|
||||||
@ApiModelProperty(value = "响应状态,成功为success,失败为fail", required = false)
|
|
||||||
private String status;
|
|
||||||
@ApiModelProperty(value = "响应返回码, 0 成功 其他失败", required = false)
|
|
||||||
private Integer code;
|
|
||||||
@ApiModelProperty(value = "响应描述", required = false)
|
|
||||||
private String msg;
|
|
||||||
@ApiModelProperty(value = "响应结果", required = false)
|
|
||||||
private Object result;
|
|
||||||
}
|
|
||||||
@ -1,64 +0,0 @@
|
|||||||
package cn.lili.modules.system.entity.vo;
|
|
||||||
|
|
||||||
|
|
||||||
import cn.lili.modules.system.entity.dos.InstantDelivery;
|
|
||||||
import cn.lili.modules.system.entity.plugin.ConfigItem;
|
|
||||||
import cn.lili.modules.system.entity.plugin.logistics.InstantDeliveryPlugin;
|
|
||||||
import com.google.common.reflect.TypeToken;
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 即时配送VO
|
|
||||||
*
|
|
||||||
* @author pikachu
|
|
||||||
* @since 2020/12/01 15:58
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@ApiModel(value = "即时配送VO")
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class InstantDeliveryVO extends InstantDelivery {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "即时配送配置项", required = true)
|
|
||||||
private List<ConfigItem> configItems;
|
|
||||||
/**
|
|
||||||
* 构建新的vo参数
|
|
||||||
*
|
|
||||||
* @param instantDelivery
|
|
||||||
*/
|
|
||||||
public InstantDeliveryVO(InstantDelivery instantDelivery) {
|
|
||||||
this.setCreateTime(instantDelivery.getCreateTime());
|
|
||||||
this.setDeleteFlag(instantDelivery.getDeleteFlag());
|
|
||||||
this.setId(instantDelivery.getId());
|
|
||||||
this.setDeliveryName(instantDelivery.getDeliveryName());
|
|
||||||
this.setDeliveryOpen(instantDelivery.getDeliveryOpen());
|
|
||||||
this.setDeliveryBean(instantDelivery.getDeliveryBean());
|
|
||||||
this.setImages(instantDelivery.getImages());
|
|
||||||
Gson gson = new Gson();
|
|
||||||
this.setConfigItems(gson.fromJson(instantDelivery.getDeliveryConfig(), new TypeToken<List<ConfigItem>>() {
|
|
||||||
}.getType()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据插件构建默认参数
|
|
||||||
*
|
|
||||||
* @param instantDeliveryPlugin
|
|
||||||
*/
|
|
||||||
public InstantDeliveryVO(InstantDeliveryPlugin instantDeliveryPlugin) {
|
|
||||||
this.setId("0");
|
|
||||||
this.setDeliveryName(instantDeliveryPlugin.getPluginName());
|
|
||||||
this.setDeliveryOpen(instantDeliveryPlugin.getOpen());
|
|
||||||
this.setDeliveryBean(instantDeliveryPlugin.getPluginId());
|
|
||||||
this.setConfigItems(instantDeliveryPlugin.getDefaultConfigItem());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,14 +0,0 @@
|
|||||||
package cn.lili.modules.system.mapper;
|
|
||||||
|
|
||||||
import cn.lili.modules.system.entity.dos.InstantDeliveryLog;
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 即时配送日志数据处理层
|
|
||||||
*
|
|
||||||
* @author pikachu
|
|
||||||
* @since 2020/11/17 8:01 下午
|
|
||||||
*/
|
|
||||||
public interface InstantDeliveryLogMapper extends BaseMapper<InstantDeliveryLog> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,14 +0,0 @@
|
|||||||
package cn.lili.modules.system.mapper;
|
|
||||||
|
|
||||||
import cn.lili.modules.system.entity.dos.InstantDelivery;
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 即时配送数据处理层
|
|
||||||
*
|
|
||||||
* @author pikachu
|
|
||||||
* @since 2020/11/17 8:01 下午
|
|
||||||
*/
|
|
||||||
public interface InstantDeliveryMapper extends BaseMapper<InstantDelivery> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,15 +0,0 @@
|
|||||||
package cn.lili.modules.system.service;
|
|
||||||
|
|
||||||
import cn.lili.modules.system.entity.dos.InstantDeliveryLog;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 即时配送日志业务层
|
|
||||||
*
|
|
||||||
* @author Chopper
|
|
||||||
* @since 2020/11/17 8:02 下午
|
|
||||||
*/
|
|
||||||
public interface InstantDeliveryLogService extends IService<InstantDeliveryLog> {
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,50 +0,0 @@
|
|||||||
package cn.lili.modules.system.service;
|
|
||||||
|
|
||||||
import cn.lili.common.vo.PageVO;
|
|
||||||
import cn.lili.modules.system.entity.dos.InstantDelivery;
|
|
||||||
import cn.lili.modules.system.entity.vo.InstantDeliveryVO;
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 即时配送业务层
|
|
||||||
*
|
|
||||||
* @author Chopper
|
|
||||||
* @since 2020/11/17 8:02 下午
|
|
||||||
*/
|
|
||||||
public interface InstantDeliveryService extends IService<InstantDelivery> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取即时配送方案
|
|
||||||
*
|
|
||||||
* @param page 数据库即时配送方案
|
|
||||||
* @param pageVO 分页数据
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
IPage<InstantDeliveryVO> getInstantDeliveryPage(IPage<InstantDelivery> page, PageVO pageVO);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据beanId查询即时配送方案
|
|
||||||
*
|
|
||||||
* @param bean beanId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
InstantDeliveryVO getInstantDeliveryConfig(String bean);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 开启某一个即时配送方案
|
|
||||||
*
|
|
||||||
* @param bean bean
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
void openInstantDelivery(String bean);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改即时配送方案
|
|
||||||
*
|
|
||||||
* @param instantDeliveryVO 即时配送方案
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
InstantDeliveryVO edit(InstantDeliveryVO instantDeliveryVO);
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
package cn.lili.modules.system.serviceimpl;
|
|
||||||
|
|
||||||
import cn.lili.modules.system.entity.dos.InstantDeliveryLog;
|
|
||||||
import cn.lili.modules.system.mapper.InstantDeliveryLogMapper;
|
|
||||||
import cn.lili.modules.system.service.InstantDeliveryLogService;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 即时配送业务层实现
|
|
||||||
*
|
|
||||||
* @author Chopper
|
|
||||||
* @since 2020/11/17 8:02 下午
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class InstantDeliveryLogServiceImpl extends ServiceImpl<InstantDeliveryLogMapper, InstantDeliveryLog> implements InstantDeliveryLogService {
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,124 +0,0 @@
|
|||||||
package cn.lili.modules.system.serviceimpl;
|
|
||||||
|
|
||||||
import cn.lili.mybatis.util.PageUtil;
|
|
||||||
import cn.lili.common.vo.PageVO;
|
|
||||||
import cn.lili.modules.system.entity.dos.InstantDelivery;
|
|
||||||
import cn.lili.modules.system.entity.plugin.logistics.InstantDeliveryPlugin;
|
|
||||||
import cn.lili.modules.system.entity.vo.InstantDeliveryVO;
|
|
||||||
import cn.lili.modules.system.mapper.InstantDeliveryMapper;
|
|
||||||
import cn.lili.modules.system.service.InstantDeliveryService;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import org.elasticsearch.ResourceNotFoundException;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 即时配送业务层实现
|
|
||||||
*
|
|
||||||
* @author pikachu
|
|
||||||
* @since 2020/11/17 8:02 下午
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public class InstantDeliveryServiceImpl extends ServiceImpl<InstantDeliveryMapper, InstantDelivery> implements InstantDeliveryService {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private List<InstantDeliveryPlugin> instantDeliveryPlugins;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IPage<InstantDeliveryVO> getInstantDeliveryPage(IPage<InstantDelivery> page, PageVO pageVO) {
|
|
||||||
//获取插件和数据库中所有的就是配送方案
|
|
||||||
List<InstantDeliveryVO> resultList = this.getInstantDeliveryVOList(page);
|
|
||||||
//循环数据,对未入库的数据进行入库操作
|
|
||||||
for (InstantDeliveryVO instantDeliveryVO : resultList) {
|
|
||||||
//根据id是否为0校验 如果为0则不在数据中,进行入库操作
|
|
||||||
if (("0").equals(instantDeliveryVO.getId())) {
|
|
||||||
//入库
|
|
||||||
InstantDelivery instantDelivery = new InstantDelivery(instantDeliveryVO);
|
|
||||||
this.baseMapper.insert(instantDelivery);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
IPage<InstantDeliveryVO> iPage = new Page<>(pageVO.getPageNumber(), pageVO.getPageSize(), resultList.size());
|
|
||||||
iPage.setRecords(PageUtil.listToPage(pageVO, resultList));
|
|
||||||
return iPage;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取即时配送的方案
|
|
||||||
*
|
|
||||||
* @return 即时配送
|
|
||||||
*/
|
|
||||||
private List<InstantDeliveryVO> getInstantDeliveryVOList(IPage<InstantDelivery> page) {
|
|
||||||
//用来构建新的即时配送数据
|
|
||||||
List<InstantDeliveryVO> resultList = new ArrayList<>();
|
|
||||||
//获取即时配送数据
|
|
||||||
List<InstantDelivery> list = page.getRecords();
|
|
||||||
Map<String, InstantDelivery> map = new HashMap<>(16);
|
|
||||||
for (InstantDelivery instantDelivery : list) {
|
|
||||||
map.put(instantDelivery.getDeliveryBean(), instantDelivery);
|
|
||||||
}
|
|
||||||
//循环检查是否有新的即时配送方式,识别插入数据库
|
|
||||||
for (InstantDeliveryPlugin plugin : instantDeliveryPlugins) {
|
|
||||||
InstantDelivery instantDelivery = map.get(plugin.getPluginId());
|
|
||||||
InstantDeliveryVO result;
|
|
||||||
//如果不为空则构建vo参数,否则的话根据插件属性构建vo参数
|
|
||||||
if (instantDelivery != null) {
|
|
||||||
result = new InstantDeliveryVO(instantDelivery);
|
|
||||||
} else {
|
|
||||||
result = new InstantDeliveryVO(plugin);
|
|
||||||
}
|
|
||||||
resultList.add(result);
|
|
||||||
}
|
|
||||||
return resultList;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public InstantDeliveryVO getInstantDeliveryConfig(String bean) {
|
|
||||||
//根据bean获取即时配送方案
|
|
||||||
QueryWrapper queryWrapper = new QueryWrapper();
|
|
||||||
queryWrapper.eq("delivery_bean", bean);
|
|
||||||
InstantDelivery instantDelivery = this.baseMapper.selectOne(queryWrapper);
|
|
||||||
if (instantDelivery == null) {
|
|
||||||
throw new ResourceNotFoundException("该即时配送方案不存在");
|
|
||||||
}
|
|
||||||
return new InstantDeliveryVO(instantDelivery);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void openInstantDelivery(String bean) {
|
|
||||||
//关闭所有配送方案
|
|
||||||
UpdateWrapper<InstantDelivery> updateWrapper = new UpdateWrapper();
|
|
||||||
updateWrapper.set("delivery_open", 0);
|
|
||||||
this.update(updateWrapper);
|
|
||||||
//开启当前配送方案
|
|
||||||
updateWrapper = new UpdateWrapper();
|
|
||||||
updateWrapper.eq("delivery_bean", bean);
|
|
||||||
updateWrapper.set("delivery_open", 1);
|
|
||||||
this.update(updateWrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public InstantDeliveryVO edit(InstantDeliveryVO instantDeliveryVO) {
|
|
||||||
//校验此方案是否存在
|
|
||||||
this.getInstantDeliveryConfig(instantDeliveryVO.getDeliveryBean());
|
|
||||||
//修改即时配送方案
|
|
||||||
Gson gson = new Gson();
|
|
||||||
UpdateWrapper<InstantDelivery> updateWrapper = new UpdateWrapper<>();
|
|
||||||
updateWrapper.set("delivery_config", gson.toJson(instantDeliveryVO.getConfigItems()));
|
|
||||||
updateWrapper.eq("delivery_bean", instantDeliveryVO.getDeliveryBean());
|
|
||||||
this.update(updateWrapper);
|
|
||||||
return instantDeliveryVO;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,90 +0,0 @@
|
|||||||
package cn.lili.controller.setting;
|
|
||||||
|
|
||||||
import cn.lili.common.enums.ResultUtil;
|
|
||||||
import cn.lili.common.vo.PageVO;
|
|
||||||
import cn.lili.common.vo.ResultMessage;
|
|
||||||
import cn.lili.modules.system.entity.dos.InstantDelivery;
|
|
||||||
import cn.lili.modules.system.entity.plugin.ConfigItem;
|
|
||||||
import cn.lili.modules.system.entity.vo.InstantDeliveryVO;
|
|
||||||
import cn.lili.modules.system.service.InstantDeliveryService;
|
|
||||||
import cn.lili.mybatis.util.PageUtil;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
|
||||||
import io.swagger.annotations.ApiImplicitParams;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 管理端,即时配送接口
|
|
||||||
*
|
|
||||||
* @author pikachu
|
|
||||||
* @since 2020/11/17 7:56 下午
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@Api(tags = "管理端,即时配送接口")
|
|
||||||
@RequestMapping("/manager/instant-delivery")
|
|
||||||
public class InstantDeliveryManagerController {
|
|
||||||
@Autowired
|
|
||||||
private InstantDeliveryService instantDeliveryService;
|
|
||||||
|
|
||||||
@GetMapping(value = "/getByPage")
|
|
||||||
@ApiOperation(value = "分页获取")
|
|
||||||
public ResultMessage<IPage<InstantDeliveryVO>> getByPage(PageVO page) {
|
|
||||||
//查询数据
|
|
||||||
IPage<InstantDelivery> data = instantDeliveryService.page(PageUtil.initPage(page));
|
|
||||||
//组织数据结构
|
|
||||||
IPage<InstantDeliveryVO> newData = instantDeliveryService.getInstantDeliveryPage(data, page);
|
|
||||||
//返回数据
|
|
||||||
return ResultUtil.data(newData);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation(value = "修改即时配送方案参数", response = InstantDeliveryVO.class)
|
|
||||||
@PutMapping(value = "/{bean}/config")
|
|
||||||
@ApiImplicitParams({
|
|
||||||
@ApiImplicitParam(name = "bean", value = "即时配送bean", required = true, dataType = "String", paramType = "path"),
|
|
||||||
@ApiImplicitParam(name = "config", value = "即时配送参数", required = true, dataType = "String", paramType = "body")
|
|
||||||
})
|
|
||||||
public ResultMessage<InstantDeliveryVO> edit(@PathVariable String bean, @RequestBody List<ConfigItem> config) {
|
|
||||||
InstantDeliveryVO instantDeliveryVO = new InstantDeliveryVO();
|
|
||||||
instantDeliveryVO.setDeliveryBean(bean);
|
|
||||||
instantDeliveryVO.setConfigItems(config);
|
|
||||||
return ResultUtil.data(this.instantDeliveryService.edit(instantDeliveryVO));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation(value = "获取即时配送的配置", response = InstantDeliveryVO.class)
|
|
||||||
@GetMapping("/{bean}")
|
|
||||||
@ApiImplicitParam(name = "bean", value = "即时配送bean id", required = true, dataType = "String", paramType = "path")
|
|
||||||
public ResultMessage<InstantDeliveryVO> getInstantDeliverySetting(@PathVariable String bean) {
|
|
||||||
return ResultUtil.data(this.instantDeliveryService.getInstantDeliveryConfig(bean));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "开启即时配送方案", response = String.class)
|
|
||||||
@PutMapping("/{bean}/open")
|
|
||||||
@ApiImplicitParam(name = "bean", value = "bean", required = true, dataType = "String", paramType = "path")
|
|
||||||
public ResultMessage<String> open(@PathVariable String bean) {
|
|
||||||
this.instantDeliveryService.openInstantDelivery(bean);
|
|
||||||
return ResultUtil.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "修改封面图片", response = String.class)
|
|
||||||
@PutMapping("/{bean}/image")
|
|
||||||
@ApiImplicitParams({
|
|
||||||
@ApiImplicitParam(name = "bean", value = "即时配送bean", required = true, dataType = "String", paramType = "path"),
|
|
||||||
@ApiImplicitParam(name = "images", value = "封面图片", required = true, dataType = "String", paramType = "query")
|
|
||||||
})
|
|
||||||
public ResultMessage<Boolean> open(@PathVariable String bean, String images) {
|
|
||||||
InstantDelivery instantDelivery = this.instantDeliveryService.getOne(new QueryWrapper<InstantDelivery>().eq("delivery_bean", bean));
|
|
||||||
if (instantDelivery != null) {
|
|
||||||
instantDelivery.setImages(images);
|
|
||||||
return ResultUtil.data(instantDeliveryService.updateById(instantDelivery));
|
|
||||||
}
|
|
||||||
return ResultUtil.data(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user