电子面单

This commit is contained in:
caihongcheng 2022-05-09 09:27:30 +08:00
parent 7cbf638822
commit b91c8e34c2
18 changed files with 828 additions and 21 deletions

View File

@ -61,4 +61,26 @@ ALTER TABLE li_member ADD INDEX query_mobile (`mobile`) COMMENT 'query_member';
-- 会员签到唯一索引 惠券查询索引
ALTER TABLE li_member_sign ADD INDEX query_create_time (`create_time`) COMMENT 'query_create_time';
ALTER TABLE li_member_sign ADD INDEX query_member_id (`member_id`) COMMENT 'query_member_id';
ALTER TABLE li_member_sign add unique uk_member_day (member_id, create_time) COMMENT 'uk_member_day';
ALTER TABLE li_member_sign add unique uk_member_day (member_id, create_time) COMMENT 'uk_member_day';
/**增加店铺发货信息**/
ALTER TABLE li_store_detail ADD `sales_consignor_address_id` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '发货地址id';
ALTER TABLE li_store_detail ADD `sales_consignor_address_path` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '发货地址名称';
ALTER TABLE li_store_detail ADD `sales_consignor_detail` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '发货详细地址';
ALTER TABLE li_store_detail ADD `sales_consignor_mobile` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '发货人手机';
ALTER TABLE li_store_detail ADD `sales_consignor_name` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '发货人姓名';
/**增加电子面单店铺信息**/
ALTER TABLE `li_store_logistics` ADD `customer_name` varchar(255) DEFAULT NULL COMMENT '客户代码';
ALTER TABLE `li_store_logistics` ADD `customer_pwd` varchar(255) DEFAULT NULL COMMENT '客户密码';
ALTER TABLE `li_store_logistics` ADD `month_code` varchar(255) DEFAULT NULL COMMENT '月结号/密钥';
ALTER TABLE `li_store_logistics` ADD `send_site` varchar(255) DEFAULT NULL COMMENT '归属网点';
ALTER TABLE `li_store_logistics` ADD `send_staff` varchar(255) DEFAULT NULL COMMENT '收件快递员';
ALTER TABLE `li_store_logistics` ADD `face_sheet_flag` bit(1) DEFAULT NULL COMMENT '是否使用电子面单';
/**是否使用电子面单标志**/
ALTER TABLE li_store_logistics RENAME COLUMN is_face_sheet TO face_sheet_flag;

View File

@ -0,0 +1,35 @@
package cn.lili.controller.common;
import cn.lili.common.enums.ResultUtil;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.system.entity.enums.SettingEnum;
import cn.lili.modules.system.service.SettingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 滑块验证码接口
*
* @author Chopper
* @since 2020/11/26 15:41
*/
@Slf4j
@RestController
@RequestMapping("/common/common/site")
@Api(tags = "系统基础设置接口")
public class SiteController {
@Autowired
private SettingService settingService;
@ApiOperation(value = "获取系统基础信息")
@GetMapping
public ResultMessage<Object> getFileList() {
return ResultUtil.data(settingService.get(SettingEnum.BASE_SETTING.name()));
}
}

View File

@ -0,0 +1,17 @@
package cn.lili.modules.kdBrid.service;
/**
* 快递鸟电子面单业务层实现
*
* @author chc
* @since 2022-4-12 10:12:43
*/
public interface KdNiaoService {
/**
* 生成电子面单
* @param orderSn 订单编号
* @param logisticsId 物流公司
* @return 电子面单模板
*/
String createElectronicsFaceSheet(String orderSn, String logisticsId) throws Exception;
}

View File

@ -0,0 +1,383 @@
package cn.lili.modules.kdBrid.serviceImpl;
import cn.hutool.core.text.CharSequenceUtil;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException;
import cn.lili.common.security.OperationalJudgment;
import cn.lili.modules.kdBrid.service.KdNiaoService;
import cn.lili.modules.member.service.StoreLogisticsService;
import cn.lili.modules.order.order.aop.OrderLogPoint;
import cn.lili.modules.order.order.entity.dos.Order;
import cn.lili.modules.order.order.entity.dos.OrderItem;
import cn.lili.modules.order.order.entity.enums.DeliverStatusEnum;
import cn.lili.modules.order.order.entity.enums.OrderStatusEnum;
import cn.lili.modules.order.order.service.OrderItemService;
import cn.lili.modules.order.order.service.OrderService;
import cn.lili.modules.store.entity.dos.StoreLogistics;
import cn.lili.modules.store.entity.dto.StoreDeliverGoodsAddressDTO;
import cn.lili.modules.store.service.StoreDetailService;
import cn.lili.modules.system.entity.dos.Logistics;
import cn.lili.modules.system.entity.dos.Setting;
import cn.lili.modules.system.entity.dto.KuaidiSetting;
import cn.lili.modules.system.entity.enums.SettingEnum;
import cn.lili.modules.system.service.LogisticsService;
import cn.lili.modules.system.service.SettingService;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.gson.Gson;
import groovy.util.logging.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 快递鸟电子面单业务层实现
*
* @author chc
* @since 2022-4-12 10:12:43
*/
@Service
@Slf4j
public class KdNiaoServiceImpl implements KdNiaoService {
/**
* 订单货物
*/
@Autowired
OrderItemService orderItemService;
/**
* 订单
*/
@Autowired
OrderService orderService;
/**
* 物流公司
*/
@Autowired
LogisticsService logisticsService;
/**
* 商家店铺
*/
@Autowired
StoreDetailService storeDetailService;
/**
* 配置
*/
@Autowired
SettingService settingService;
/**
* 店铺-物流
*/
@Autowired
StoreLogisticsService storeLogisticsService;
@Override
@OrderLogPoint(description = "'订单['+#orderSn+']发货,发货单号['+#logisticsNo+'],已打印电子面单'", orderSn = "#orderSn")
@Transactional(rollbackFor = Exception.class)
public String createElectronicsFaceSheet(String orderSn, String logisticsId) throws Exception {
//电子面单模板
String printTemplate = null;
//获取订单及子订单
Order order = OperationalJudgment.judgment(orderService.getBySn(orderSn));
List<OrderItem> orderItems = orderItemService.getByOrderSn(orderSn);
Setting setting = settingService.get(SettingEnum.KUAIDI_SETTING.name());
if (CharSequenceUtil.isBlank(setting.getSettingValue())) {
throw new ServiceException(ResultCode.LOGISTICS_NOT_SETTING);
}
KuaidiSetting kuaidiSetting = new Gson().fromJson(setting.getSettingValue(), KuaidiSetting.class);
//ID
String EBusinessID = kuaidiSetting.getEbusinessID();
//KEY
String AppKey = kuaidiSetting.getAppKey();
//请求url
String ReqURL = kuaidiSetting.getReqURL();
//如果订单未发货并且订单状态值等于待发货
if (order.getDeliverStatus().equals(DeliverStatusEnum.UNDELIVERED.name()) && order.getOrderStatus().equals(OrderStatusEnum.UNDELIVERED.name())) {
//获取对应物流
Logistics logistics = logisticsService.getById(logisticsId);
//物流为空,抛出异常
if (logistics == null) {
throw new ServiceException(ResultCode.ORDER_LOGISTICS_ERROR);
}
//获取店家的物流信息
LambdaQueryWrapper<StoreLogistics> lambdaQueryWrapper = Wrappers.lambdaQuery();
lambdaQueryWrapper.eq(StoreLogistics::getLogisticsId, logisticsId);
lambdaQueryWrapper.eq(StoreLogistics::getStoreId, order.getStoreId());
StoreLogistics storeLogistics = storeLogisticsService.getOne(lambdaQueryWrapper);
//获取店家信息
StoreDeliverGoodsAddressDTO storeDeliverGoodsAddressDTO = storeDetailService.getStoreDeliverGoodsAddressDto(order.getStoreId());
//收件人地址
String[] ConsigneeAddress = order.getConsigneeAddressPath().split(",");
//发件人地址
String[] consignorAddress = storeDeliverGoodsAddressDTO.getSalesConsignorAddressPath().split(",");
//组装快递鸟应用级参数
String resultDate = "{" +
"'OrderCode': '" + orderSn + "'," + //订单编码
"'ShipperCode': '" + logistics.getCode() + "'," + //快递公司编码
"'CustomerName': '"+storeLogistics.getCustomerName()+"'," +//客户编码
"'CustomerPwd': '"+storeLogistics.getCustomerPwd()+"'," + //客户密码
"'MonthCode': '"+storeLogistics.getMonthCode()+"'," + //密钥
"'SendSite': '"+storeLogistics.getSendSite()+"'," + //归属网点
"'SendStaff': '"+storeLogistics.getSendStaff()+"'," + //收件快递员
"'PayType': 1," +
"'ExpType': 1," +
//发件人信息
"'Sender': {" +
"'Name': '" + storeDeliverGoodsAddressDTO.getSalesConsignorName() + "'," +
"'Mobile': '" + storeDeliverGoodsAddressDTO.getSalesConsignorMobile() + "'," +
"'ProvinceName': '" + consignorAddress[0] + "'," + //
"'CityName': '" + consignorAddress[1] + "'," + //
"'ExpAreaName': '" + consignorAddress[2] + "'," + //
"'Address': '" + storeDeliverGoodsAddressDTO.getSalesConsignorDetail() + "'" + //发件人详细地址
"}," +
//收件人信息
"'Receiver': {" +
"'Name': '" + order.getConsigneeName() + "'," +
"'Mobile': '" + order.getConsigneeMobile() + "'," +
"'ProvinceName': '" + ConsigneeAddress[0] + "'," + //
"'CityName': '" + ConsigneeAddress[1] + "'," + //
"'ExpAreaName': '" + ConsigneeAddress[2] + "'," + //
"'Address': '" + order.getConsigneeDetail() + "'" + //收件人详细地址
"}," +
//商品信息
"'Commodity': [";
//子订单信息
for (OrderItem orderItem : orderItems) {
resultDate = resultDate + "{" +
"'GoodsName': '" + orderItem.getGoodsName() + "'," +
"'Goodsquantity': '" + orderItem.getNum() + "'" +
"},";
}
resultDate = resultDate + "]," +
"'Quantity': 1," + //包裹数
"'IsReturnPrintTemplate':1,"+ //生成电子面单模板
"'Remark': '" + order.getRemark() + "'"+//商家备注
"}";
//组织系统级参数
Map<String, String> params = new HashMap<>();
//进行格式加密
params.put("RequestData", urlEncoder(resultDate, "UTF-8"));
params.put("EBusinessID", EBusinessID);
params.put("RequestType", "1007");
String dataSign = encrypt(resultDate, AppKey, "UTF-8");
params.put("DataSign", dataSign);
params.put("DataType", "2");
// 以form表单形式提交post请求post请求体中包含了应用级参数和系统级参数
String result = sendPost(ReqURL, params);
//根据公司业务处理返回的信息......
JSONObject obj = JSONObject.parseObject(result);
if(!"100".equals(obj.getString("ResultCode"))){
return obj.getString("Reason");
}
JSONObject orderJson = JSONObject.parseObject(obj.getString("Order"));
//电子面单模板
printTemplate = obj.getString("PrintTemplate");
//进行发货
orderService.delivery(orderSn, orderJson.getString("LogisticCode"), logisticsId);
}
return printTemplate;
}
/**
* MD5加密
*
* @param str 内容
* @param charset 编码方式
* @throws Exception
*/
@SuppressWarnings("unused")
private String MD5(String str, String charset) throws Exception {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(str.getBytes(charset));
byte[] result = md.digest();
StringBuffer sb = new StringBuffer(32);
for (int i = 0; i < result.length; i++) {
int val = result[i] & 0xff;
if (val <= 0xf) {
sb.append("0");
}
sb.append(Integer.toHexString(val));
}
return sb.toString().toLowerCase();
}
/**
* base64编码
*
* @param str 内容
* @param charset 编码方式di
* @throws UnsupportedEncodingException
*/
private String base64(String str, String charset) throws UnsupportedEncodingException {
return base64Encode(str.getBytes(charset));
}
@SuppressWarnings("unused")
private String urlEncoder(String str, String charset) throws UnsupportedEncodingException {
return URLEncoder.encode(str, charset);
}
/**
* 电商Sign签名生成
*
* @param content 内容
* @param keyValue Appkey
* @param charset 编码方式
* @return DataSign签名
* @throws UnsupportedEncodingException ,Exception
*/
@SuppressWarnings("unused")
private String encrypt(String content, String keyValue, String charset) throws Exception {
if (keyValue != null) {
return base64(MD5(content + keyValue, charset), charset);
}
return base64(MD5(content, charset), charset);
}
/**
* 向指定 URL 发送POST方法的请求
*
* @param url 发送请求的 URL
* @param params 请求的参数集合
* @return 远程资源的响应结果
*/
@SuppressWarnings("unused")
private String sendPost(String url, Map<String, String> params) {
OutputStreamWriter out = null;
BufferedReader in = null;
StringBuilder result = new StringBuilder();
try {
URL realUrl = new URL(url);
HttpURLConnection conn = (HttpURLConnection) realUrl.openConnection();
//发送POST请求必须设置如下两行
conn.setDoOutput(true);
conn.setDoInput(true);
//POST方法
conn.setRequestMethod("POST");
//设置通用的请求属性
conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("user-agent",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.connect();
//获取URLConnection对象对应的输出流
out = new OutputStreamWriter(conn.getOutputStream(), StandardCharsets.UTF_8);
//发送请求参数
if (params != null) {
StringBuilder param = new StringBuilder();
for (Map.Entry<String, String> entry : params.entrySet()) {
if (param.length() > 0) {
param.append("&");
}
param.append(entry.getKey());
param.append("=");
param.append(entry.getValue());
}
out.write(param.toString());
}
//flush输出流的缓冲
out.flush();
//定义BufferedReader输入流来读取URL的响应
in = new BufferedReader(
new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8));
String line;
while ((line = in.readLine()) != null) {
result.append(line);
}
} catch (Exception e) {
e.printStackTrace();
}
//使用finally块来关闭输出流输入流
finally {
try {
if (out != null) {
out.close();
}
if (in != null) {
in.close();
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
return result.toString();
}
private static final char[] BASE64_ENCODE_CHARS = new char[]{
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '+', '/'};
public static String base64Encode(byte[] data) {
StringBuffer sb = new StringBuffer();
int len = data.length;
int i = 0;
int b1, b2, b3;
while (i < len) {
b1 = data[i++] & 0xff;
if (i == len) {
sb.append(BASE64_ENCODE_CHARS[b1 >>> 2]);
sb.append(BASE64_ENCODE_CHARS[(b1 & 0x3) << 4]);
sb.append("==");
break;
}
b2 = data[i++] & 0xff;
if (i == len) {
sb.append(BASE64_ENCODE_CHARS[b1 >>> 2]);
sb.append(BASE64_ENCODE_CHARS[((b1 & 0x03) << 4) | ((b2 & 0xf0) >>> 4)]);
sb.append(BASE64_ENCODE_CHARS[(b2 & 0x0f) << 2]);
sb.append("=");
break;
}
b3 = data[i++] & 0xff;
sb.append(BASE64_ENCODE_CHARS[b1 >>> 2]);
sb.append(BASE64_ENCODE_CHARS[((b1 & 0x03) << 4) | ((b2 & 0xf0) >>> 4)]);
sb.append(BASE64_ENCODE_CHARS[((b2 & 0x0f) << 2) | ((b3 & 0xc0) >>> 6)]);
sb.append(BASE64_ENCODE_CHARS[b3 & 0x3f]);
}
return sb.toString();
}
}

View File

@ -21,7 +21,7 @@ public interface StoreLogisticsMapper extends BaseMapper<StoreLogistics> {
* @param storeId 店铺ID
* @return 物流公司列表
*/
@Select("SELECT l.* FROM li_logistics l RIGHT JOIN li_store_logistics sl ON l.id=sl.logistics_id WHERE sl.store_id=#{storeId} AND l.disabled='OPEN'")
@Select("SELECT l.id as logistics_id,l.name FROM li_logistics l RIGHT JOIN li_store_logistics sl ON l.id=sl.logistics_id WHERE sl.store_id=#{storeId} AND l.disabled='OPEN'")
List<StoreLogisticsVO> getSelectedStoreLogistics(String storeId);
/**
@ -39,7 +39,35 @@ public interface StoreLogisticsMapper extends BaseMapper<StoreLogistics> {
* @param storeId 店铺列表
* @return 店铺地址VO列表
*/
@Select("SELECT *, ( SELECT sl.id FROM li_store_logistics sl WHERE l.id = sl.logistics_id AND sl.store_id=#{storeId} ) AS selected FROM li_logistics l WHERE l.disabled='OPEN';")
@Select("SELECT id as logistics_id , `name` , ( SELECT sl.id FROM li_store_logistics sl WHERE l.id = sl.logistics_id AND sl.store_id=#{storeId} ) AS selected,(SELECT sl.face_sheet_flag FROM li_store_logistics sl WHERE l.id = sl.logistics_id AND sl.store_id = #{storeId}) as face_sheet_flag FROM li_logistics l WHERE l.disabled='OPEN';")
//@Select("SELECT *, ( SELECT sl.id FROM li_store_logistics sl WHERE l.id = sl.logistics_id AND sl.store_id=#{storeId} ) AS selected FROM li_logistics l WHERE l.disabled='OPEN';")
List<StoreLogisticsVO> getStoreLogistics(String storeId);
/**
* 店铺已选择的物流公司
* @param storeId 店铺Id
* @return 物流公司列表
*/
@Select("SELECT sl.logistics_id,l.name,sl.face_sheet_flag FROM li_logistics l INNER JOIN li_store_logistics sl on sl.logistics_id=l.id WHERE l.disabled = 'OPEN' AND store_id=#{storeId};")
List<StoreLogisticsVO> getOpenStoreLogistics(String storeId);
/**
* 店铺未选择的物流公司
* @param storeId 店铺Id
* @return 物流公司列表
*/
@Select("SELECT id as logistics_id,name FROM li_logistics WHERE id not in(SELECT logistics_id FROM li_store_logistics WHERE store_id=#{storeId}) AND disabled = 'OPEN'")
List<StoreLogisticsVO> getCloseStroreLogistics(String storeId);
/**
* 获取店铺选择的物流公司并使用了电子面单
*
* @param storeId 店铺ID
* @return 物流公司列表
*/
@Select("SELECT id as logistics_id , `name` FROM li_logistics WHERE disabled='OPEN'" +
"AND id in(SELECT logistics_id FROM li_store_logistics WHERE store_id=#{storeId} and face_sheet_flag=1)")
List<StoreLogisticsVO> getSelectedStoreLogisticsUseFaceSheet(String storeId);
}

View File

@ -1,6 +1,7 @@
package cn.lili.modules.member.service;
import cn.lili.modules.store.entity.dos.StoreLogistics;
import cn.lili.modules.store.entity.dto.StoreLogisticsCustomerDTO;
import cn.lili.modules.system.entity.vo.StoreLogisticsVO;
import com.baomidou.mybatisplus.extension.service.IService;
@ -45,7 +46,48 @@ public interface StoreLogisticsService extends IService<StoreLogistics> {
* @param storeId 店铺id
* @return 店铺物流公司
*/
StoreLogistics add(String logisticsId, String storeId);
StoreLogistics add(String logisticsId, String storeId, StoreLogisticsCustomerDTO storeLogisticsCustomerDTO);
/**
* 获取当前店铺已选择的物流公司并使用电子面单列表
*
* @param storeId 店铺id
* @return 物流公司列表
*/
List<StoreLogisticsVO> getStoreSelectedLogisticsUseFaceSheet(String storeId);
/**
* 修改店铺-物流公司电子面单参数
* @param logisticsId 物流公司设置id
* @param storeId 店铺id
* @return 店铺物流公司
*/
StoreLogistics update(String logisticsId, String storeId, StoreLogisticsCustomerDTO storeLogisticsCustomerDTO);
/**
* 获取店铺物流信息回填
* @param logisticsId 物流id
* @return 店铺物流信息
*/
StoreLogistics getStoreLogisticsInfo(String logisticsId);
/**
* 获取当前店铺已开启的物流公司列表
*
* @param storeId 店铺id
* @return 物流公司列表
*/
List<StoreLogisticsVO> getOpenStoreLogistics(String storeId);
/**
* 获取当前店铺未开启的物流公司列表
*
* @param storeId 店铺id
* @return 物流公司列表
*/
List<StoreLogisticsVO> getCloseStoreLogistics(String storeId);
}

View File

@ -1,8 +1,10 @@
package cn.lili.modules.member.serviceimpl;
import cn.lili.common.security.context.UserContext;
import cn.lili.modules.member.mapper.StoreLogisticsMapper;
import cn.lili.modules.member.service.StoreLogisticsService;
import cn.lili.modules.store.entity.dos.StoreLogistics;
import cn.lili.modules.store.entity.dto.StoreLogisticsCustomerDTO;
import cn.lili.modules.system.entity.vo.StoreLogisticsVO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@ -10,6 +12,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Objects;
/**
* 物流公司业务层实现
@ -37,16 +40,57 @@ public class StoreLogisticsServiceImpl extends ServiceImpl<StoreLogisticsMapper,
}
@Override
public StoreLogistics add(String logisticsId, String storeId) {
public List<StoreLogisticsVO> getStoreSelectedLogisticsUseFaceSheet(String storeId) {
return this.baseMapper.getSelectedStoreLogisticsUseFaceSheet(storeId);
}
@Override
public StoreLogistics update(String logisticsId, String storeId,StoreLogisticsCustomerDTO storeLogisticsCustomerDTO) {
LambdaQueryWrapper<StoreLogistics> lambdaQueryWrapper = Wrappers.lambdaQuery();
lambdaQueryWrapper.eq(StoreLogistics::getLogisticsId, logisticsId);
lambdaQueryWrapper.eq(StoreLogistics::getStoreId, storeId);
this.remove(lambdaQueryWrapper);
StoreLogistics ResultstoreLogistics = new StoreLogistics(storeLogisticsCustomerDTO);
ResultstoreLogistics.setStoreId(storeId);
ResultstoreLogistics.setLogisticsId(logisticsId);
this.save(ResultstoreLogistics);
return ResultstoreLogistics;
}
@Override
public StoreLogistics getStoreLogisticsInfo( String logisticsId) {
String storeId = Objects.requireNonNull(UserContext.getCurrentUser()).getStoreId();
return this.getOne(new LambdaQueryWrapper<StoreLogistics>().eq(StoreLogistics::getStoreId,storeId).eq(StoreLogistics::getLogisticsId,logisticsId));
}
@Override
public List<StoreLogisticsVO> getOpenStoreLogistics(String storeId) {
List<StoreLogisticsVO> openStoreLogistics = this.baseMapper.getOpenStoreLogistics(storeId);
for(StoreLogisticsVO storeLogisticsVO:openStoreLogistics){
storeLogisticsVO.setSelected("1");
}
return openStoreLogistics;
}
@Override
public List<StoreLogisticsVO> getCloseStoreLogistics(String storeId) {
return this.baseMapper.getCloseStroreLogistics(storeId);
}
@Override
public StoreLogistics add(String logisticsId, String storeId, StoreLogisticsCustomerDTO storeLogisticsCustomerDTO){
//判断是否已经选择过如果没有选择则进行添加
LambdaQueryWrapper<StoreLogistics> lambdaQueryWrapper = Wrappers.lambdaQuery();
lambdaQueryWrapper.eq(StoreLogistics::getLogisticsId, logisticsId);
lambdaQueryWrapper.eq(StoreLogistics::getStoreId, storeId);
StoreLogistics storeLogistics=null;
if (this.getOne(lambdaQueryWrapper) == null) {
StoreLogistics storeLogistics = new StoreLogistics(storeId, logisticsId);
this.save(storeLogistics);
return storeLogistics;
}
storeLogistics=new StoreLogistics(storeLogisticsCustomerDTO);
storeLogistics.setStoreId(storeId);
storeLogistics.setLogisticsId(logisticsId);
this.save(storeLogistics);
return storeLogistics;
}
return null;
}

View File

@ -184,6 +184,22 @@ public class StoreDetail extends BaseIdEntity {
@ApiModelProperty(value = "福禄appKEY商户key")
private String appMerchantKey;
//店铺发货地址
@ApiModelProperty(value = "发货人姓名")
private String salesConsignorName;
@ApiModelProperty(value = "发件人手机")
private String salesConsignorMobile;
@ApiModelProperty(value = "发件人地址Id ''分割")
private String salesConsignorAddressId;
@ApiModelProperty(value = "发件人地址名称, ''分割")
private String salesConsignorAddressPath;
@ApiModelProperty(value = "发件人详细地址")
private String salesConsignorDetail;
public StoreDetail(Store store, AdminStoreApplyDTO adminStoreApplyDTO) {
this.storeId = store.getId();
//设置店铺公司信息设置店铺银行信息设置店铺其他信息

View File

@ -1,5 +1,6 @@
package cn.lili.modules.store.entity.dos;
import cn.lili.modules.store.entity.dto.StoreLogisticsCustomerDTO;
import cn.lili.mybatis.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
@ -32,5 +33,32 @@ public class StoreLogistics extends BaseEntity {
@NotNull
private String logisticsId;
@ApiModelProperty(value = "客户代码")
private String customerName;
@ApiModelProperty(value = "客户密码")
private String customerPwd;
@ApiModelProperty(value = "密钥")
private String monthCode;
@ApiModelProperty(value = "归属网点/网点编码")
private String sendSite;
@ApiModelProperty(value = "收件快递员")
private String sendStaff;
@ApiModelProperty(value = "是否使用电子面单")
private boolean faceSheetFlag;
public StoreLogistics(StoreLogisticsCustomerDTO storeLogisticsCustomerDTO){
this.customerName=storeLogisticsCustomerDTO.getCustomerName();
this.customerPwd=storeLogisticsCustomerDTO.getCustomerPwd();
this.sendSite=storeLogisticsCustomerDTO.getSendSite();
this.sendStaff=storeLogisticsCustomerDTO.getSendStaff();
this.monthCode=storeLogisticsCustomerDTO.getMonthCode();
this.faceSheetFlag=storeLogisticsCustomerDTO.isFaceSheetFlag();
}
}

View File

@ -0,0 +1,30 @@
package cn.lili.modules.store.entity.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 店铺发货地址
*
* @author chc
* @since 2022-4-12 10:14:05
*/
@Data
public class StoreDeliverGoodsAddressDTO {
@ApiModelProperty(value = "发货人姓名")
private String salesConsignorName;
@ApiModelProperty(value = "发货人手机号")
private String salesConsignorMobile;
@ApiModelProperty(value = "地址Id ''分割")
private String salesConsignorAddressId;
@ApiModelProperty(value = "地址名称, ''分割")
private String salesConsignorAddressPath;
@ApiModelProperty(value = "详细地址")
private String salesConsignorDetail;
}

View File

@ -0,0 +1,35 @@
package cn.lili.modules.store.entity.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 商家使用电子面单客户号DTO
*
* @author chc
* @since 2022-4-13 10:00:58
*/
@Data
@ApiModel
public class StoreLogisticsCustomerDTO {
@ApiModelProperty(value = "客户代码")
private String customerName;
@ApiModelProperty(value = "客户密码")
private String customerPwd;
@ApiModelProperty(value = "密钥")
private String monthCode;
@ApiModelProperty(value = "归属网点/网点编码")
private String sendSite;
@ApiModelProperty(value = "收件快递员")
private String sendStaff;
@ApiModelProperty(value = "是否使用电子面单")
private boolean faceSheetFlag;
}

View File

@ -4,6 +4,7 @@ import cn.hutool.core.date.DateTime;
import cn.lili.modules.store.entity.dos.StoreDetail;
import cn.lili.modules.store.entity.dto.FuLuConfigureDTO;
import cn.lili.modules.store.entity.dto.StoreAfterSaleAddressDTO;
import cn.lili.modules.store.entity.dto.StoreDeliverGoodsAddressDTO;
import cn.lili.modules.store.entity.dto.StoreSettlementDay;
import cn.lili.modules.store.entity.vos.StoreBasicInfoVO;
import cn.lili.modules.store.entity.vos.StoreDetailVO;
@ -98,4 +99,13 @@ public interface StoreDetailMapper extends BaseMapper<StoreDetail> {
*/
@Select("SELECT * FROM li_store_detail WHERE store_id=#{storeId}")
StoreOtherVO getLicencePhoto(String storeId);
/***
* 获取店铺发货地址
* @param storeId 店铺ID
* @return 店铺发货地址DTO
*/
@Select("select s.sales_consignor_name,s.sales_consignor_mobile,s.sales_consignor_address_id,s.sales_consignor_address_path,s.sales_consignor_detail "+
"from li_store_detail s where s.store_id=#{storeId}")
StoreDeliverGoodsAddressDTO getStoreDeliverGoodsAddressDto(String storeId);
}

View File

@ -3,10 +3,7 @@ package cn.lili.modules.store.service;
import cn.hutool.core.date.DateTime;
import cn.lili.modules.store.entity.dos.Store;
import cn.lili.modules.store.entity.dos.StoreDetail;
import cn.lili.modules.store.entity.dto.FuLuConfigureDTO;
import cn.lili.modules.store.entity.dto.StoreAfterSaleAddressDTO;
import cn.lili.modules.store.entity.dto.StoreSettingDTO;
import cn.lili.modules.store.entity.dto.StoreSettlementDay;
import cn.lili.modules.store.entity.dto.*;
import cn.lili.modules.store.entity.vos.StoreBasicInfoVO;
import cn.lili.modules.store.entity.vos.StoreDetailVO;
import cn.lili.modules.store.entity.vos.StoreManagementCategoryVO;
@ -157,4 +154,28 @@ public interface StoreDetailService extends IService<StoreDetail> {
* @param dateTime 结算日
*/
void updateSettlementDay(String storeId, DateTime dateTime);
/**
* 获取当前登录店铺发件地址
*
* @return 店铺售后发件地址
*/
StoreDeliverGoodsAddressDTO getStoreDeliverGoodsAddressDto();
/**
* 获取某一个店铺的发货寄件地址信息
*
* @param id 店铺ID
* @return 店铺发件地址
*/
StoreDeliverGoodsAddressDTO getStoreDeliverGoodsAddressDto(String id);
/**
* 修改当前登录店铺发件地址
*
* @param storeDeliverGoodsAddressDto 店铺发货信息DTO
* @return 店铺售后发件地址
*/
boolean editStoreDeliverGoodsAddressDTO(StoreDeliverGoodsAddressDTO storeDeliverGoodsAddressDto);
}

View File

@ -13,10 +13,7 @@ import cn.lili.modules.goods.service.GoodsService;
import cn.lili.modules.search.utils.EsIndexUtil;
import cn.lili.modules.store.entity.dos.Store;
import cn.lili.modules.store.entity.dos.StoreDetail;
import cn.lili.modules.store.entity.dto.FuLuConfigureDTO;
import cn.lili.modules.store.entity.dto.StoreAfterSaleAddressDTO;
import cn.lili.modules.store.entity.dto.StoreSettingDTO;
import cn.lili.modules.store.entity.dto.StoreSettlementDay;
import cn.lili.modules.store.entity.dto.*;
import cn.lili.modules.store.entity.vos.StoreBasicInfoVO;
import cn.lili.modules.store.entity.vos.StoreDetailVO;
import cn.lili.modules.store.entity.vos.StoreManagementCategoryVO;
@ -127,6 +124,34 @@ public class StoreDetailServiceImpl extends ServiceImpl<StoreDetailMapper, Store
return this.baseMapper.getSettlementStore(day);
}
@Override
public StoreDeliverGoodsAddressDTO getStoreDeliverGoodsAddressDto() {
String storeId = Objects.requireNonNull(UserContext.getCurrentUser().getStoreId());
return this.baseMapper.getStoreDeliverGoodsAddressDto(storeId);
}
@Override
public StoreDeliverGoodsAddressDTO getStoreDeliverGoodsAddressDto(String id) {
StoreDeliverGoodsAddressDTO storeDeliverGoodsAddressDto = this.baseMapper.getStoreDeliverGoodsAddressDto(id);
if(storeDeliverGoodsAddressDto ==null ){
storeDeliverGoodsAddressDto = new StoreDeliverGoodsAddressDTO();
}
return storeDeliverGoodsAddressDto;
}
@Override
public boolean editStoreDeliverGoodsAddressDTO(StoreDeliverGoodsAddressDTO storeDeliverGoodsAddressDto) {
String storeId = Objects.requireNonNull(UserContext.getCurrentUser().getStoreId());
LambdaUpdateWrapper<StoreDetail> lambdaUpdateWrapper = Wrappers.lambdaUpdate();
lambdaUpdateWrapper.set(StoreDetail::getSalesConsignorName,storeDeliverGoodsAddressDto.getSalesConsignorName());
lambdaUpdateWrapper.set(StoreDetail::getSalesConsignorMobile,storeDeliverGoodsAddressDto.getSalesConsignorMobile());
lambdaUpdateWrapper.set(StoreDetail::getSalesConsignorAddressId,storeDeliverGoodsAddressDto.getSalesConsignorAddressId());
lambdaUpdateWrapper.set(StoreDetail::getSalesConsignorAddressPath,storeDeliverGoodsAddressDto.getSalesConsignorAddressPath());
lambdaUpdateWrapper.set(StoreDetail::getSalesConsignorDetail,storeDeliverGoodsAddressDto.getSalesConsignorDetail());
lambdaUpdateWrapper.eq(StoreDetail::getStoreId,storeId);
return this.update(lambdaUpdateWrapper);
}
/**
* 修改店铺的结算日
*

View File

@ -24,4 +24,7 @@ public class StoreLogisticsVO extends BaseEntity {
@ApiModelProperty(value = "已选择", notes = "如果已选择则有值,没有选择则无值")
private String selected;
@ApiModelProperty(value = "是否使用电子面单")
private Boolean faceSheetFlag;
}

View File

@ -7,6 +7,7 @@ import cn.lili.common.enums.ResultUtil;
import cn.lili.common.security.OperationalJudgment;
import cn.lili.common.security.context.UserContext;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.kdBrid.service.KdNiaoService;
import cn.lili.modules.member.entity.dto.MemberAddressDTO;
import cn.lili.modules.member.service.StoreLogisticsService;
import cn.lili.modules.order.order.entity.dto.OrderExportDTO;
@ -61,6 +62,12 @@ public class OrderStoreController {
@Autowired
private StoreLogisticsService storeLogisticsService;
/**
* 快递鸟电子面单
*/
@Autowired
private KdNiaoService kdNiaoService;
@ApiOperation(value = "查询订单列表")
@GetMapping
@ -174,4 +181,16 @@ public class OrderStoreController {
public ResultMessage<List<OrderExportDTO>> queryExportOrder(OrderSearchParams orderSearchParams) {
return ResultUtil.data(orderService.queryExportOrder(orderSearchParams));
}
@PreventDuplicateSubmissions
@ApiOperation(value = "创建电子面单")
@PostMapping(value = "/{orderSn}/createElectronicsFaceSheet")
@ApiImplicitParams({
@ApiImplicitParam(name = "orderSn", value = "订单号", required = true, paramType = "path"),
@ApiImplicitParam(name = "logisticsId", value = "物流公司", required = true, dataType = "String", paramType = "query")
})
public ResultMessage<Object> createElectronicsFaceSheet(@NotNull(message = "参数非法") @PathVariable String orderSn,
@NotNull(message = "请选择物流公司") String logisticsId) throws Exception{
return ResultUtil.data(kdNiaoService.createElectronicsFaceSheet(orderSn,logisticsId));
}
}

View File

@ -6,10 +6,12 @@ import cn.lili.common.security.context.UserContext;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.member.service.StoreLogisticsService;
import cn.lili.modules.store.entity.dos.StoreLogistics;
import cn.lili.modules.store.entity.dto.StoreLogisticsCustomerDTO;
import cn.lili.modules.system.entity.vo.StoreLogisticsVO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.*;
@ -38,7 +40,12 @@ public class LogisticsStoreController {
@GetMapping
public ResultMessage<List<StoreLogisticsVO>> get() {
String storeId = Objects.requireNonNull(UserContext.getCurrentUser()).getStoreId();
return ResultUtil.data(storeLogisticsService.getStoreLogistics(storeId));
//获取已开启的物流公司
List<StoreLogisticsVO> storeLogistics = storeLogisticsService.getOpenStoreLogistics(storeId);
//获取未开启的物流公司
List<StoreLogisticsVO> closeStoreLogistics = storeLogisticsService.getCloseStoreLogistics(storeId);
storeLogistics.addAll(closeStoreLogistics);
return ResultUtil.data(storeLogistics);
}
@ApiOperation(value = "获取商家已选择物流公司列表")
@ -49,11 +56,13 @@ public class LogisticsStoreController {
}
@ApiOperation(value = "选择物流公司")
@ApiImplicitParam(name = "logisticsId", value = "物流公司ID", required = true, paramType = "path")
@ApiImplicitParams({
@ApiImplicitParam(name = "logisticsId", value = "物流公司ID", required = true, paramType = "path"),
})
@PostMapping("/{logisticsId}")
public ResultMessage<StoreLogistics> checked(@PathVariable String logisticsId) {
public ResultMessage<StoreLogistics> checked(@PathVariable String logisticsId,@RequestBody StoreLogisticsCustomerDTO storeLogisticsCustomerDTO) {
String storeId = Objects.requireNonNull(UserContext.getCurrentUser()).getStoreId();
return ResultUtil.data(storeLogisticsService.add(logisticsId, storeId));
return ResultUtil.data(storeLogisticsService.add(logisticsId, storeId,storeLogisticsCustomerDTO));
}
@ -66,4 +75,28 @@ public class LogisticsStoreController {
return ResultUtil.data(remove);
}
@ApiOperation(value = "修改电子面单参数")
@ApiImplicitParams({
@ApiImplicitParam(name = "logisticsId", value = "物流公司ID", required = true, paramType = "path"),
})
@PutMapping("/{logisticsId}/updateStoreLogistics")
public ResultMessage<StoreLogistics> updateStoreLogistics(@PathVariable String logisticsId,StoreLogisticsCustomerDTO storeLogisticsCustomerDTO){
String storeId = Objects.requireNonNull(UserContext.getCurrentUser()).getStoreId();
return ResultUtil.data(storeLogisticsService.update(logisticsId, storeId,storeLogisticsCustomerDTO));
}
@ApiOperation(value = "获取商家已选择物流公司并且使用电子面单列表")
@GetMapping("/getCheckedFaceSheet")
public ResultMessage<List<StoreLogisticsVO>> getCheckedFaceSheet() {
String storeId = Objects.requireNonNull(UserContext.getCurrentUser()).getStoreId();
return ResultUtil.data(storeLogisticsService.getStoreSelectedLogisticsUseFaceSheet(storeId));
}
@ApiOperation(value = "获取店铺-物流公司详细信息")
@ApiImplicitParam(name = "logisticsId", value = "物流公司ID", required = true, paramType = "path")
@GetMapping("/{logisticsId}/getStoreLogistics")
public ResultMessage<StoreLogistics> getStoreLogistics(@PathVariable String logisticsId){
return ResultUtil.data(storeLogisticsService.getStoreLogisticsInfo(logisticsId));
}
}

View File

@ -5,6 +5,7 @@ import cn.lili.common.enums.ResultUtil;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.store.entity.dto.FuLuConfigureDTO;
import cn.lili.modules.store.entity.dto.StoreAfterSaleAddressDTO;
import cn.lili.modules.store.entity.dto.StoreDeliverGoodsAddressDTO;
import cn.lili.modules.store.entity.dto.StoreSettingDTO;
import cn.lili.modules.store.entity.vos.StoreVO;
import cn.lili.modules.store.service.StoreDetailService;
@ -103,4 +104,19 @@ public class StoreSettingsController {
boolean result = storeDetailService.editFuLuConfigureDTO(fuLuConfigureDTO);
return ResultUtil.data(result);
}
@ApiOperation(value = "获取商家发货地址")
@GetMapping("/storeDeliverGoodsAddress")
public ResultMessage<StoreDeliverGoodsAddressDTO> getStoreDeliverGoodsAddress(){
return ResultUtil.data(storeDetailService.getStoreDeliverGoodsAddressDto());
}
@ApiOperation(value = "修改商家发货地址")
@PutMapping("/storeDeliverGoodsAddress")
public ResultMessage<Object> editStoreDeliverGoodsAddress(@Valid StoreDeliverGoodsAddressDTO storeDeliverGoodsAddressDTO) {
//修改商家退货收件地址
boolean result = storeDetailService.editStoreDeliverGoodsAddressDTO(storeDeliverGoodsAddressDTO);
return ResultUtil.data(result);
}
}