|
@@ -14,6 +14,7 @@ import com.kmall.manager.manager.wechat.wxglobal.WechatGlobalUtil;
|
|
|
import com.kmall.manager.manager.wechat.wxglobal.dto.WechatGlobalQueryApiResult;
|
|
|
import com.kmall.manager.manager.wechat.wxglobal.dto.WechatGlobalRefundQueryResult;
|
|
|
import com.kmall.manager.manager.wechat.wxtemplate.WxTemplate;
|
|
|
+import com.kmall.schedule.dao.MkDistSellStatisMapper;
|
|
|
import com.kmall.schedule.dao.OrderWXPayRecordMapper;
|
|
|
import com.kmall.schedule.dao.QzGroupMapper;
|
|
|
import com.kmall.schedule.dao.QzOrderMapper;
|
|
@@ -22,6 +23,7 @@ import com.kmall.common.utils.wechat.WechatRefundApiResult;
|
|
|
import com.kmall.common.utils.wechat.WechatRefundQueryResult;
|
|
|
import com.kmall.manager.manager.wechat.wxtemplate.TemplateData;
|
|
|
import com.kmall.manager.manager.wechat.wxtemplate.WxTemplateUtil;
|
|
|
+import com.kmall.schedule.entity.MkDistSellStatisEntity;
|
|
|
import com.kmall.schedule.quartz.OrderTask;
|
|
|
import com.kmall.schedule.entity.MngChangeJobEntity;
|
|
|
import com.kmall.schedule.entity.StoreMngChangeJobEntity;
|
|
@@ -54,6 +56,8 @@ public class QzOrderService {
|
|
|
private QzOrderMapper qzOrderMapper;
|
|
|
@Autowired
|
|
|
private OrderWXPayRecordMapper orderWXPayRecordMapper;
|
|
|
+ @Autowired
|
|
|
+ private MkDistSellStatisMapper mkDistSellStatisMapper;
|
|
|
|
|
|
/**
|
|
|
* todo 一期暂时不实现团购
|
|
@@ -1238,6 +1242,114 @@ public class QzOrderService {
|
|
|
logger.info(">>>>>>>>>>>>>>>>>>>>receiptOrderAutoComment is end ");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 方法描述:用户确认收货后,记录商品分销购买记录
|
|
|
+ * 1分钟更新
|
|
|
+ */
|
|
|
+ @Transactional
|
|
|
+ public void receiptOrderSaveDistSellStatis(){
|
|
|
+ logger.info(">>>>>>>>>>>>>>>>>>>>receiptOrderSaveDistSellStatis is start ");
|
|
|
+ logger.info(">>>>>>>>>>>>>>>>>>>>用户确认收货后,记录商品分销购买记录 ");
|
|
|
+ Map configMap = qzOrderMapper.querySysConfigByKey("IS_DIST_SELL");
|
|
|
+ String status = MapUtils.getString("status", configMap);
|
|
|
+ if(Dict.status.item_1.getItem().equalsIgnoreCase(status)) {//1为启用渠道销售功能
|
|
|
+ // 获取收货后的订单
|
|
|
+ List<Map> receiptOrderList = qzOrderMapper.queryReceiptOrderByDistList();
|
|
|
+ if (null != receiptOrderList && receiptOrderList.size() > 0) {
|
|
|
+ for (Map map : receiptOrderList) {
|
|
|
+ String orderSn = MapUtils.getString("orderSn", map);
|
|
|
+ Integer orderGoodsId = MapUtils.getInteger("orderGoodsId", map);
|
|
|
+ Integer storeId = MapUtils.getInteger("storeId", map);
|
|
|
+ Integer userId = MapUtils.getInteger("userId", map);
|
|
|
+ Long goodsId = MapUtils.getLong("goodsId", map);
|
|
|
+ BigDecimal goodsPrice = MapUtils.getBigDecimal("goodsPrice", map);
|
|
|
+ Integer thirdMerchSn = MapUtils.getInteger("thirdMerchSn", map);
|
|
|
+ Integer supplierId = MapUtils.getInteger("supplierId", map);
|
|
|
+ Integer distId = MapUtils.getInteger("distId", map);
|
|
|
+ String distFlag = MapUtils.getString("distFlag", map);
|
|
|
+ String distChnlId = MapUtils.getString("distChnlId", map);
|
|
|
+
|
|
|
+ String allocType = MapUtils.getString("allocType", map);
|
|
|
+ Integer sell_alloc_history_id = MapUtils.getInteger("sell_alloc_history_id", map);
|
|
|
+
|
|
|
+ String expendDistIds = MapUtils.getString("expendDistIds", map);
|
|
|
+ String expendDistLines = MapUtils.getString("expendDistLines", map);
|
|
|
+
|
|
|
+ MkDistSellStatisEntity mkDistSellStatisEntity = new MkDistSellStatisEntity();
|
|
|
+ mkDistSellStatisEntity.setUserId(userId);
|
|
|
+ mkDistSellStatisEntity.setOrderGoodsId(orderGoodsId);
|
|
|
+ mkDistSellStatisEntity.setOrderSn(orderSn);
|
|
|
+ mkDistSellStatisEntity.setGoodsId(String.valueOf(goodsId));
|
|
|
+ mkDistSellStatisEntity.setGoodsPrice(goodsPrice);
|
|
|
+ mkDistSellStatisEntity.setThirdMerchSn(thirdMerchSn);
|
|
|
+ mkDistSellStatisEntity.setSupplierId(supplierId);
|
|
|
+ mkDistSellStatisEntity.setDistId(distId);
|
|
|
+ mkDistSellStatisEntity.setDistChnlId(distChnlId);
|
|
|
+ mkDistSellStatisEntity.setDistFlag(distFlag);
|
|
|
+// mkDistSellStatisEntity.setAllocType(allocType);
|
|
|
+ mkDistSellStatisEntity.setSellAllocHistoryId(sell_alloc_history_id);
|
|
|
+ mkDistSellStatisEntity.setIsValid("0");
|
|
|
+ mkDistSellStatisEntity.setCreateTime(new Date());
|
|
|
+ mkDistSellStatisEntity.setModTime(new Date());
|
|
|
+ mkDistSellStatisEntity.setStoreId(storeId);
|
|
|
+
|
|
|
+ List<Integer> expendDistIdList = getExpendDistId(expendDistIds);//支出对应分销商
|
|
|
+ List<Double> expendDistLinesList = getExpendDistLines(expendDistLines);//商品支出对应佣金额度
|
|
|
+
|
|
|
+ for (int i = 0; i < expendDistIdList.size(); i++) {
|
|
|
+ Map hierMap = new HashMap();
|
|
|
+ hierMap.put("distId", expendDistIdList.get(i));
|
|
|
+// hierMap.put("pdistId", distId);
|
|
|
+ hierMap.put("distChnlId", distChnlId);
|
|
|
+ Map distHierMap = qzOrderMapper.queryMkDistHierById(hierMap);
|
|
|
+ if (!StringUtils.isNullOrEmpty(distHierMap)) {
|
|
|
+ String level = MapUtils.getString("hierLvl", distHierMap);
|
|
|
+ BigDecimal price = new BigDecimal(0);
|
|
|
+ Double expendDistPrice = expendDistLinesList.get(i);
|
|
|
+ if (allocType.equalsIgnoreCase(Dict.allocType.item_00.getItem())) {//比例,公式:商品购买价格*设置比例
|
|
|
+ price = goodsPrice.multiply(BigDecimal.valueOf(expendDistPrice));
|
|
|
+ } else if (allocType.equalsIgnoreCase(Dict.allocType.item_10.getItem())) {//金额
|
|
|
+ //// TODO: 2019/4/12 金额
|
|
|
+ price = BigDecimal.valueOf(expendDistPrice);
|
|
|
+ }
|
|
|
+
|
|
|
+ mkDistSellStatisEntity.setExpendDistId(expendDistIdList.get(i));
|
|
|
+ mkDistSellStatisEntity.setExpendDistLevel(level);
|
|
|
+ mkDistSellStatisEntity.setExpendDistPrice(price);
|
|
|
+ mkDistSellStatisEntity.setExpendSource("");
|
|
|
+ mkDistSellStatisMapper.save(mkDistSellStatisEntity);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Map isScanMap = new HashMap();
|
|
|
+ isScanMap.put("orderGoodsId", orderGoodsId);
|
|
|
+ isScanMap.put("isDistSellScan", Dict.isDistSellScan.item_1.getItem());
|
|
|
+ qzOrderMapper.updateOrderGoodsIsScan(isScanMap);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ logger.info(">>>>>>>>>>>>>>>>>>>>确认收货订单没有数据 ");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ logger.info(">>>>>>>>>>>>>>>>>>>>receiptOrderSaveDistSellStatis is end ");
|
|
|
+
|
|
|
+ }
|
|
|
+ private List<Integer> getExpendDistId(String expendDistIds){
|
|
|
+ List<Integer> expendDistIdList = new ArrayList<>();
|
|
|
+ String[] expendIds = expendDistIds.split(",");
|
|
|
+ for (int i=0;i<expendIds.length;i++){
|
|
|
+ expendDistIdList.add(Integer.parseInt(expendIds[i]));
|
|
|
+ }
|
|
|
+ return expendDistIdList;
|
|
|
+ }
|
|
|
+ private List<Double> getExpendDistLines(String expendDistLines){
|
|
|
+ List<Double> expendDistLinesList = new ArrayList<>();
|
|
|
+ String[] expendLines = expendDistLines.split(",");
|
|
|
+ for (int i=0;i<expendLines.length;i++){
|
|
|
+ expendDistLinesList.add(Double.parseDouble(expendLines[i]));
|
|
|
+ }
|
|
|
+ return expendDistLinesList;
|
|
|
+ }
|
|
|
+
|
|
|
public long getDateBetween(Date begin, Date end) {
|
|
|
SimpleDateFormat dfs = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|