|
|
@@ -0,0 +1,120 @@
|
|
|
+package com.kxs.transfer.api.service.user;
|
|
|
+
|
|
|
+import cn.hutool.core.date.DatePattern;
|
|
|
+import cn.hutool.core.date.LocalDateTimeUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.aliyun.dts.subscribe.clients.record.OperationType;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.kxs.common.core.constant.enums.KindTypeEnum;
|
|
|
+import com.kxs.transfer.api.mapper.user.KxsLeaderByOrderInfoMapper;
|
|
|
+import com.kxs.transfer.api.mapper.user.KxsLeaderByOrderMapper;
|
|
|
+import com.kxs.transfer.api.model.table.DMLData;
|
|
|
+import com.kxs.transfer.api.model.table.FieldData;
|
|
|
+import com.kxs.user.api.model.KxsChangeTypeKind;
|
|
|
+import com.kxs.user.api.model.KxsLeaderAccountLog;
|
|
|
+import com.kxs.user.api.model.KxsLeaderByOrder;
|
|
|
+import com.kxs.user.api.model.KxsLeaderByOrderInfo;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.json.JsonObject;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 盟主兑换订单表(KxsLeaderByOrder)表服务实现类
|
|
|
+ *
|
|
|
+ * @author 系统
|
|
|
+ * @since 2024-07-18 14:51:20
|
|
|
+ */
|
|
|
+@Service("kxsLeaderByOrderService")
|
|
|
+@RequiredArgsConstructor
|
|
|
+public class KxsLeaderByOrderService extends ServiceImpl<KxsLeaderByOrderMapper, KxsLeaderByOrder> {
|
|
|
+
|
|
|
+ private final KxsLeaderByOrderInfoMapper kxsLeaderByOrderInfoMapper;
|
|
|
+
|
|
|
+
|
|
|
+ public void changeData(DMLData dmlData) {
|
|
|
+
|
|
|
+ //修改的字段值
|
|
|
+ Map<String, Object> validFieldDataMap = dmlData.getValidFieldDataMap();
|
|
|
+ Map<String, FieldData> fieldDataMap = dmlData.getFieldDataMap();
|
|
|
+
|
|
|
+ //修改的字段
|
|
|
+ List<String> changeFieldList = dmlData.getChangeFieldList();
|
|
|
+ //操作的主键
|
|
|
+ int id = Integer.parseInt(dmlData.getId());
|
|
|
+
|
|
|
+ KxsLeaderByOrder byOrder = new KxsLeaderByOrder();
|
|
|
+ byOrder.setId(id);
|
|
|
+ //操作类型
|
|
|
+ OperationType operation = dmlData.getOperation();
|
|
|
+ if (operation.equals(OperationType.DELETE) || operation.equals(OperationType.UPDATE)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (fieldDataMap.get("Remark").getValue() != null) {
|
|
|
+ String remark = fieldDataMap.get("Remark").getValue().toString();
|
|
|
+ if (!"兑换机具券".equals(remark)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ byOrder.setOrderSn(fieldDataMap.get("SeoKeyword").getValue().toString());
|
|
|
+ }
|
|
|
+ if (fieldDataMap.get("SeoTitle").getValue() != null) {
|
|
|
+ String string = fieldDataMap.get("SeoTitle").getValue().toString();
|
|
|
+ String seoKeyword = fieldDataMap.get("SeoKeyword").getValue().toString();
|
|
|
+ Integer userId = Integer.valueOf(fieldDataMap.get("UserId").getValue().toString());
|
|
|
+ JSONArray jsonArray = JSON.parseArray(string);
|
|
|
+ List<JSONObject> applyData = new ArrayList<>();
|
|
|
+ int total = 0;
|
|
|
+ for (Object data : jsonArray) {
|
|
|
+ JSONObject jsonObject = (JSONObject) data;
|
|
|
+ JSONObject apply = new JSONObject();
|
|
|
+ apply.put("num",jsonObject.get("Num"));
|
|
|
+ apply.put("type",jsonObject.get("Type"));
|
|
|
+ applyData.add(apply);
|
|
|
+ total = total + jsonObject.getInteger("Num");
|
|
|
+ }
|
|
|
+ byOrder.setUserId(userId);
|
|
|
+ byOrder.setByNum(total);
|
|
|
+ byOrder.setByData(JSON.toJSONString(applyData));
|
|
|
+ byOrder.setOrderSn(seoKeyword);
|
|
|
+
|
|
|
+ baseMapper.insert(byOrder);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public void changeInfoData(DMLData dmlData) {
|
|
|
+
|
|
|
+ Map<String, FieldData> fieldDataMap = dmlData.getFieldDataMap();
|
|
|
+
|
|
|
+ KxsLeaderByOrderInfo byOrderInfo = new KxsLeaderByOrderInfo();
|
|
|
+ //操作类型
|
|
|
+ OperationType operation = dmlData.getOperation();
|
|
|
+ if (operation.equals(OperationType.DELETE) || operation.equals(OperationType.UPDATE)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (fieldDataMap.get("QueryCount").getValue() != null) {
|
|
|
+ Integer orderId = Integer.valueOf(fieldDataMap.get("QueryCount").getValue().toString());
|
|
|
+ String code = fieldDataMap.get("SnNo").getValue().toString();
|
|
|
+ byOrderInfo.setOrderId(orderId);
|
|
|
+ byOrderInfo.setTicketCode(code);
|
|
|
+ KxsLeaderByOrder byOrder = baseMapper.selectById(orderId);
|
|
|
+ if (byOrder != null) {
|
|
|
+ byOrderInfo.setUserId(byOrder.getUserId());
|
|
|
+ }
|
|
|
+
|
|
|
+ kxsLeaderByOrderInfoMapper.insert(byOrderInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+}
|
|
|
+
|