|
@@ -0,0 +1,101 @@
|
|
|
+package com.kmall.admin.service.impl;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.kmall.admin.dao.SalesDetailMapper;
|
|
|
+import com.kmall.admin.dto.NewSystemFormatEntiy;
|
|
|
+import com.kmall.admin.service.SalesDetailService;
|
|
|
+import com.kmall.common.constant.Dict;
|
|
|
+import com.kmall.common.utils.DateUtils;
|
|
|
+import com.kmall.common.utils.HttpUtil;
|
|
|
+import org.apache.commons.logging.Log;
|
|
|
+import org.apache.commons.logging.LogFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+public class SalesDetailServiceImpl implements SalesDetailService {
|
|
|
+
|
|
|
+ private static Log logger = LogFactory.getLog(SalesDetailService.class);
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SalesDetailMapper salesDetailMapper;
|
|
|
+ /**
|
|
|
+ *向eccs推送销售明细数据
|
|
|
+ */
|
|
|
+ public void pushSalesDetailData() {
|
|
|
+ logger.info(">>>>>>>>>>>>>>>>>>>>pushSalesDetailData is start ");
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ String date = DateUtils.formatDate(DateUtils.addDate(new Date(),-1),"yyyy-MM-dd");
|
|
|
+ params.put("startTime", DateUtils.getDateAddTime(date,"00:00:00"));
|
|
|
+ params.put("endTime",DateUtils.getDateAddTime(date,"23:59:59"));
|
|
|
+
|
|
|
+// params.put("startTime", "2021-03-07 00:00:00");
|
|
|
+// params.put("endTime","2021-03-11 23:59:59");
|
|
|
+ params.put("isOnfiilineOrder","1");
|
|
|
+ List<NewSystemFormatEntiy> dtoList = salesDetailMapper.querySalesSystemFormatList(params);
|
|
|
+ pushDateEccs(dtoList);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void pushDateEccs(List<NewSystemFormatEntiy> dtoList) {
|
|
|
+ String valueUrl = salesDetailMapper.querySalesByKey("SALES_DETAIL_DATA_URL");
|
|
|
+
|
|
|
+ if (dtoList.size() > 0) {
|
|
|
+
|
|
|
+ dtoList.forEach(bean ->{
|
|
|
+ BigDecimal unitSold = new BigDecimal(bean.getUnitSold());
|
|
|
+ // 如果是退货
|
|
|
+ String orderStatus = bean.getOrderStatus();
|
|
|
+ if (Dict.orderStatus.item_401.getItem().equals(orderStatus)){
|
|
|
+ bean.setSaleReturnType("整单退货");
|
|
|
+ bean.setTransactionType("退货");
|
|
|
+ }else{
|
|
|
+ bean.setTransactionType("销售");
|
|
|
+ }
|
|
|
+ // 设置综合税额
|
|
|
+ BigDecimal totalSalesIncTax = new BigDecimal(bean.getTotalSalesInclTax());
|
|
|
+ // 设置实际销售额
|
|
|
+ bean.setCurrentPrice(totalSalesIncTax.divide(unitSold,2,BigDecimal.ROUND_HALF_UP).setScale(2,BigDecimal.ROUND_HALF_UP).toEngineeringString());
|
|
|
+ NewSystemFormatEntiy merchMsg = salesDetailMapper.queryMerch(bean.getMerchSn());
|
|
|
+ if(merchMsg!=null){
|
|
|
+ bean.setThirdMerchSn(merchMsg.getThirdMerchSn());
|
|
|
+ bean.setThirdMerchSnName(merchMsg.getThirdMerchSnName());
|
|
|
+ bean.setMerchSnName(merchMsg.getMerchSnName());
|
|
|
+ }
|
|
|
+ String msg = HttpUtil.doPostJson(valueUrl, JSON.toJSONString(bean));
|
|
|
+ if(msg!=null&&!msg.equals("")){
|
|
|
+ Map<String, Object> kmallMsg = com.alibaba.fastjson.JSONObject.toJavaObject(JSON.parseObject(msg), Map.class);
|
|
|
+ if (kmallMsg.get("code").equals(200)) {
|
|
|
+ bean.setSalesDetStatus("1");
|
|
|
+ } else {
|
|
|
+ bean.setSalesDetStatus("2");
|
|
|
+ }
|
|
|
+ bean.setSalesDetMsg(msg);
|
|
|
+ salesDetailMapper.writebackSalesDet(bean);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 重推接口
|
|
|
+ */
|
|
|
+ public void pushSalesDetailDataAgain() {
|
|
|
+ logger.info(">>>>>>>>>>>>>>>>>>>>pushSalesDetailDataAgain is start ");
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ String date = DateUtils.formatDate(DateUtils.addDate(new Date(),-1),"yyyy-MM-dd");
|
|
|
+ params.put("startTime", DateUtils.getDateAddTime(date,"00:00:00"));
|
|
|
+ params.put("endTime",DateUtils.getDateAddTime(date,"23:59:59"));
|
|
|
+ List<NewSystemFormatEntiy> dtoList = salesDetailMapper.querySalesAgain(params);
|
|
|
+ pushDateEccs(dtoList);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|