From 14ce522539b053e22e4db94ae55410333d873043 Mon Sep 17 00:00:00 2001 From: Chopper Date: Thu, 4 Nov 2021 10:19:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E6=97=A0=E6=95=88=E4=B8=9A?= =?UTF-8?q?=E5=8A=A1=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/entity/dos/InstantDelivery.java | 67 ---- .../system/entity/dos/InstantDeliveryLog.java | 99 ----- .../entity/enums/InstantDeliveryUrl.java | 63 ---- .../system/entity/plugin/ConfigItem.java | 40 -- .../system/entity/plugin/RadioOption.java | 28 -- .../logistics/InstantDeliveryPlugin.java | 119 ------ .../plugin/logistics/dada/DadaPlugin.java | 346 ------------------ .../dada/enums/DadaOrderStatusEnum.java | 68 ---- .../logistics/dada/vo/DdOrderBackVO.java | 50 --- .../entity/vo/InstantDeliveryResultVO.java | 24 -- .../system/entity/vo/InstantDeliveryVO.java | 64 ---- .../mapper/InstantDeliveryLogMapper.java | 14 - .../system/mapper/InstantDeliveryMapper.java | 14 - .../service/InstantDeliveryLogService.java | 15 - .../service/InstantDeliveryService.java | 50 --- .../InstantDeliveryLogServiceImpl.java | 21 -- .../InstantDeliveryServiceImpl.java | 124 ------- .../InstantDeliveryManagerController.java | 90 ----- 18 files changed, 1296 deletions(-) delete mode 100644 framework/src/main/java/cn/lili/modules/system/entity/dos/InstantDelivery.java delete mode 100644 framework/src/main/java/cn/lili/modules/system/entity/dos/InstantDeliveryLog.java delete mode 100644 framework/src/main/java/cn/lili/modules/system/entity/enums/InstantDeliveryUrl.java delete mode 100644 framework/src/main/java/cn/lili/modules/system/entity/plugin/ConfigItem.java delete mode 100644 framework/src/main/java/cn/lili/modules/system/entity/plugin/RadioOption.java delete mode 100644 framework/src/main/java/cn/lili/modules/system/entity/plugin/logistics/InstantDeliveryPlugin.java delete mode 100644 framework/src/main/java/cn/lili/modules/system/entity/plugin/logistics/dada/DadaPlugin.java delete mode 100644 framework/src/main/java/cn/lili/modules/system/entity/plugin/logistics/dada/enums/DadaOrderStatusEnum.java delete mode 100644 framework/src/main/java/cn/lili/modules/system/entity/plugin/logistics/dada/vo/DdOrderBackVO.java delete mode 100644 framework/src/main/java/cn/lili/modules/system/entity/vo/InstantDeliveryResultVO.java delete mode 100644 framework/src/main/java/cn/lili/modules/system/entity/vo/InstantDeliveryVO.java delete mode 100644 framework/src/main/java/cn/lili/modules/system/mapper/InstantDeliveryLogMapper.java delete mode 100644 framework/src/main/java/cn/lili/modules/system/mapper/InstantDeliveryMapper.java delete mode 100644 framework/src/main/java/cn/lili/modules/system/service/InstantDeliveryLogService.java delete mode 100644 framework/src/main/java/cn/lili/modules/system/service/InstantDeliveryService.java delete mode 100644 framework/src/main/java/cn/lili/modules/system/serviceimpl/InstantDeliveryLogServiceImpl.java delete mode 100644 framework/src/main/java/cn/lili/modules/system/serviceimpl/InstantDeliveryServiceImpl.java delete mode 100644 manager-api/src/main/java/cn/lili/controller/setting/InstantDeliveryManagerController.java diff --git a/framework/src/main/java/cn/lili/modules/system/entity/dos/InstantDelivery.java b/framework/src/main/java/cn/lili/modules/system/entity/dos/InstantDelivery.java deleted file mode 100644 index becf1ec8..00000000 --- a/framework/src/main/java/cn/lili/modules/system/entity/dos/InstantDelivery.java +++ /dev/null @@ -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())); - } - -} \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/system/entity/dos/InstantDeliveryLog.java b/framework/src/main/java/cn/lili/modules/system/entity/dos/InstantDeliveryLog.java deleted file mode 100644 index b62f8959..00000000 --- a/framework/src/main/java/cn/lili/modules/system/entity/dos/InstantDeliveryLog.java +++ /dev/null @@ -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)); - } - - -} \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/system/entity/enums/InstantDeliveryUrl.java b/framework/src/main/java/cn/lili/modules/system/entity/enums/InstantDeliveryUrl.java deleted file mode 100644 index bee60f65..00000000 --- a/framework/src/main/java/cn/lili/modules/system/entity/enums/InstantDeliveryUrl.java +++ /dev/null @@ -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; - } - -} - diff --git a/framework/src/main/java/cn/lili/modules/system/entity/plugin/ConfigItem.java b/framework/src/main/java/cn/lili/modules/system/entity/plugin/ConfigItem.java deleted file mode 100644 index c0659173..00000000 --- a/framework/src/main/java/cn/lili/modules/system/entity/plugin/ConfigItem.java +++ /dev/null @@ -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 options; - - -} diff --git a/framework/src/main/java/cn/lili/modules/system/entity/plugin/RadioOption.java b/framework/src/main/java/cn/lili/modules/system/entity/plugin/RadioOption.java deleted file mode 100644 index 0c558303..00000000 --- a/framework/src/main/java/cn/lili/modules/system/entity/plugin/RadioOption.java +++ /dev/null @@ -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; - -} diff --git a/framework/src/main/java/cn/lili/modules/system/entity/plugin/logistics/InstantDeliveryPlugin.java b/framework/src/main/java/cn/lili/modules/system/entity/plugin/logistics/InstantDeliveryPlugin.java deleted file mode 100644 index cc401872..00000000 --- a/framework/src/main/java/cn/lili/modules/system/entity/plugin/logistics/InstantDeliveryPlugin.java +++ /dev/null @@ -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 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); -} diff --git a/framework/src/main/java/cn/lili/modules/system/entity/plugin/logistics/dada/DadaPlugin.java b/framework/src/main/java/cn/lili/modules/system/entity/plugin/logistics/dada/DadaPlugin.java deleted file mode 100644 index 4986fcc4..00000000 --- a/framework/src/main/java/cn/lili/modules/system/entity/plugin/logistics/dada/DadaPlugin.java +++ /dev/null @@ -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 getDefaultConfigItem() { - List 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 requestJson = getConfig(config, jsonArray.toString()); - String result = HttpUtils.doPostWithJson(url + InstantDeliveryUrl.DD_ADD_SHOP.getUrl(), requestJson); - //组织返回参数 - InstantDeliveryResultVO instantDeliveryResultVO = JSONUtil.toBean(result, InstantDeliveryResultVO.class); - Map map = (Map) instantDeliveryResultVO.getResult(); - List> successList = map.get("successList"); - if (successList.size() > 0) { - for (Map obj : successList) { - //如果成功调用店铺修改 将门店编码写入数据库 - UpdateWrapper updateWrapper = new UpdateWrapper(); - updateWrapper.in("id", storeDetailVO.getStoreId()); - updateWrapper.set("dd_code", obj.get("originStoreId").toString()); - storeDetailService.update(updateWrapper); - } - } - List> errorList = map.get("failedList"); - if (errorList != null && errorList.size() > 0) { - for (Map 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 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 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 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 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 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 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 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 requstJson = getConfig(config, jsonObject.toString()); - //获取所有城市编码 - String result = HttpUtils.doPostWithJson(url + InstantDeliveryUrl.DD_CITY_CODE.getUrl(), requstJson); - InstantDeliveryResultVO resultDO = JSONUtil.toBean(result, InstantDeliveryResultVO.class); - //对数据进行格式化 - - List 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); - } - -} diff --git a/framework/src/main/java/cn/lili/modules/system/entity/plugin/logistics/dada/enums/DadaOrderStatusEnum.java b/framework/src/main/java/cn/lili/modules/system/entity/plugin/logistics/dada/enums/DadaOrderStatusEnum.java deleted file mode 100644 index cde57dde..00000000 --- a/framework/src/main/java/cn/lili/modules/system/entity/plugin/logistics/dada/enums/DadaOrderStatusEnum.java +++ /dev/null @@ -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(); - } -} diff --git a/framework/src/main/java/cn/lili/modules/system/entity/plugin/logistics/dada/vo/DdOrderBackVO.java b/framework/src/main/java/cn/lili/modules/system/entity/plugin/logistics/dada/vo/DdOrderBackVO.java deleted file mode 100644 index 51980558..00000000 --- a/framework/src/main/java/cn/lili/modules/system/entity/plugin/logistics/dada/vo/DdOrderBackVO.java +++ /dev/null @@ -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; - -} diff --git a/framework/src/main/java/cn/lili/modules/system/entity/vo/InstantDeliveryResultVO.java b/framework/src/main/java/cn/lili/modules/system/entity/vo/InstantDeliveryResultVO.java deleted file mode 100644 index b9542c24..00000000 --- a/framework/src/main/java/cn/lili/modules/system/entity/vo/InstantDeliveryResultVO.java +++ /dev/null @@ -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; -} diff --git a/framework/src/main/java/cn/lili/modules/system/entity/vo/InstantDeliveryVO.java b/framework/src/main/java/cn/lili/modules/system/entity/vo/InstantDeliveryVO.java deleted file mode 100644 index b964b040..00000000 --- a/framework/src/main/java/cn/lili/modules/system/entity/vo/InstantDeliveryVO.java +++ /dev/null @@ -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 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>() { - }.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()); - } - -} \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/system/mapper/InstantDeliveryLogMapper.java b/framework/src/main/java/cn/lili/modules/system/mapper/InstantDeliveryLogMapper.java deleted file mode 100644 index 05b7d3ab..00000000 --- a/framework/src/main/java/cn/lili/modules/system/mapper/InstantDeliveryLogMapper.java +++ /dev/null @@ -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 { - -} \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/system/mapper/InstantDeliveryMapper.java b/framework/src/main/java/cn/lili/modules/system/mapper/InstantDeliveryMapper.java deleted file mode 100644 index 6c71025b..00000000 --- a/framework/src/main/java/cn/lili/modules/system/mapper/InstantDeliveryMapper.java +++ /dev/null @@ -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 { - -} \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/system/service/InstantDeliveryLogService.java b/framework/src/main/java/cn/lili/modules/system/service/InstantDeliveryLogService.java deleted file mode 100644 index 45fd3c26..00000000 --- a/framework/src/main/java/cn/lili/modules/system/service/InstantDeliveryLogService.java +++ /dev/null @@ -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 { - - -} \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/system/service/InstantDeliveryService.java b/framework/src/main/java/cn/lili/modules/system/service/InstantDeliveryService.java deleted file mode 100644 index e0b5d9d9..00000000 --- a/framework/src/main/java/cn/lili/modules/system/service/InstantDeliveryService.java +++ /dev/null @@ -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 { - - /** - * 获取即时配送方案 - * - * @param page 数据库即时配送方案 - * @param pageVO 分页数据 - * @return - */ - IPage getInstantDeliveryPage(IPage 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); - -} \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/system/serviceimpl/InstantDeliveryLogServiceImpl.java b/framework/src/main/java/cn/lili/modules/system/serviceimpl/InstantDeliveryLogServiceImpl.java deleted file mode 100644 index 3bf4ec01..00000000 --- a/framework/src/main/java/cn/lili/modules/system/serviceimpl/InstantDeliveryLogServiceImpl.java +++ /dev/null @@ -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 implements InstantDeliveryLogService { - -} \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/system/serviceimpl/InstantDeliveryServiceImpl.java b/framework/src/main/java/cn/lili/modules/system/serviceimpl/InstantDeliveryServiceImpl.java deleted file mode 100644 index 621866b0..00000000 --- a/framework/src/main/java/cn/lili/modules/system/serviceimpl/InstantDeliveryServiceImpl.java +++ /dev/null @@ -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 implements InstantDeliveryService { - - @Autowired - private List instantDeliveryPlugins; - - @Override - public IPage getInstantDeliveryPage(IPage page, PageVO pageVO) { - //获取插件和数据库中所有的就是配送方案 - List 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 iPage = new Page<>(pageVO.getPageNumber(), pageVO.getPageSize(), resultList.size()); - iPage.setRecords(PageUtil.listToPage(pageVO, resultList)); - return iPage; - } - - /** - * 获取即时配送的方案 - * - * @return 即时配送 - */ - private List getInstantDeliveryVOList(IPage page) { - //用来构建新的即时配送数据 - List resultList = new ArrayList<>(); - //获取即时配送数据 - List list = page.getRecords(); - Map 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 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 updateWrapper = new UpdateWrapper<>(); - updateWrapper.set("delivery_config", gson.toJson(instantDeliveryVO.getConfigItems())); - updateWrapper.eq("delivery_bean", instantDeliveryVO.getDeliveryBean()); - this.update(updateWrapper); - return instantDeliveryVO; - } -} \ No newline at end of file diff --git a/manager-api/src/main/java/cn/lili/controller/setting/InstantDeliveryManagerController.java b/manager-api/src/main/java/cn/lili/controller/setting/InstantDeliveryManagerController.java deleted file mode 100644 index f01e2d92..00000000 --- a/manager-api/src/main/java/cn/lili/controller/setting/InstantDeliveryManagerController.java +++ /dev/null @@ -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> getByPage(PageVO page) { - //查询数据 - IPage data = instantDeliveryService.page(PageUtil.initPage(page)); - //组织数据结构 - IPage 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 edit(@PathVariable String bean, @RequestBody List 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 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 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 open(@PathVariable String bean, String images) { - InstantDelivery instantDelivery = this.instantDeliveryService.getOne(new QueryWrapper().eq("delivery_bean", bean)); - if (instantDelivery != null) { - instantDelivery.setImages(images); - return ResultUtil.data(instantDeliveryService.updateById(instantDelivery)); - } - return ResultUtil.data(false); - } -}