|
@@ -49,6 +49,8 @@ import com.fs.course.dto.FsOrderDeliveryNoteDTO;
|
|
|
import com.fs.course.dto.OrderOpenIdTransDTO;
|
|
import com.fs.course.dto.OrderOpenIdTransDTO;
|
|
|
import com.fs.course.mapper.FsCoursePlaySourceConfigMapper;
|
|
import com.fs.course.mapper.FsCoursePlaySourceConfigMapper;
|
|
|
import com.fs.course.mapper.FsUserCompanyUserMapper;
|
|
import com.fs.course.mapper.FsUserCompanyUserMapper;
|
|
|
|
|
+import com.fs.course.mapper.FsCourseWatchLogMapper;
|
|
|
|
|
+import com.fs.course.domain.FsCourseWatchLog;
|
|
|
import com.fs.erp.domain.*;
|
|
import com.fs.erp.domain.*;
|
|
|
import com.fs.erp.dto.*;
|
|
import com.fs.erp.dto.*;
|
|
|
import com.fs.erp.dto.df.*;
|
|
import com.fs.erp.dto.df.*;
|
|
@@ -227,6 +229,9 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private FsUserCompanyUserMapper fsUserCompanyUserMapper;
|
|
private FsUserCompanyUserMapper fsUserCompanyUserMapper;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private FsCourseWatchLogMapper fsCourseWatchLogMapper;
|
|
|
|
|
+
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private FsUserAddressScrmMapper userAddressMapper;
|
|
private FsUserAddressScrmMapper userAddressMapper;
|
|
|
|
|
|
|
@@ -1314,6 +1319,16 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
orderStatusService.create(storeOrder.getId(), OrderLogEnum.CREATE_ORDER.getValue(),
|
|
orderStatusService.create(storeOrder.getId(), OrderLogEnum.CREATE_ORDER.getValue(),
|
|
|
OrderLogEnum.CREATE_ORDER.getDesc());
|
|
OrderLogEnum.CREATE_ORDER.getDesc());
|
|
|
|
|
|
|
|
|
|
+ // 商城订单归属绑定
|
|
|
|
|
+ if (Boolean.TRUE.equals(config.getEnableStoreOrderAttribution())
|
|
|
|
|
+ && storeOrder.getOrderType() != null && storeOrder.getOrderType() == 0) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ bindStoreOrderAttribution(storeOrder, userId);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("商城订单归属绑定异常,订单号:{},用户ID:{}", storeOrder.getOrderCode(), userId, e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
//加入redis,24小时自动取消
|
|
//加入redis,24小时自动取消
|
|
|
String redisKey = String.valueOf(StrUtil.format("{}{}",
|
|
String redisKey = String.valueOf(StrUtil.format("{}{}",
|
|
|
StoreConstants.REDIS_ORDER_OUTTIME_UNPAY, storeOrder.getId()));
|
|
StoreConstants.REDIS_ORDER_OUTTIME_UNPAY, storeOrder.getId()));
|
|
@@ -7220,4 +7235,56 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
// return R.ok().put("data",result);
|
|
// return R.ok().put("data",result);
|
|
|
// }
|
|
// }
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 商城订单归属绑定逻辑
|
|
|
|
|
+ * 1. 查询fs_user_company_user表,获取用户绑定的销售列表(status=1正常状态)
|
|
|
|
|
+ * 2. 如果只绑定了一个销售,直接将该销售的companyId和companyUserId绑定到订单
|
|
|
|
|
+ * 3. 如果绑定了多个销售,查询用户最近看课记录(看课时长>0),将看课记录对应的销售绑定到订单
|
|
|
|
|
+ * 4. 如果无看课记录则不绑定归属
|
|
|
|
|
+ */
|
|
|
|
|
+ private void bindStoreOrderAttribution(FsStoreOrderScrm storeOrder, Long userId) {
|
|
|
|
|
+ // 查询用户绑定的正常状态的销售列表
|
|
|
|
|
+ FsUserCompanyUser queryParam = new FsUserCompanyUser();
|
|
|
|
|
+ queryParam.setUserId(userId);
|
|
|
|
|
+ queryParam.setStatus(1);
|
|
|
|
|
+ List<FsUserCompanyUser> bindList = fsUserCompanyUserMapper.selectFsUserCompanyUserList(queryParam);
|
|
|
|
|
+
|
|
|
|
|
+ if (bindList == null || bindList.isEmpty()) {
|
|
|
|
|
+ log.info("商城订单归属:用户{}无绑定销售,不绑定归属,订单号:{}", userId, storeOrder.getOrderCode());
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Long bindCompanyId = null;
|
|
|
|
|
+ Long bindCompanyUserId = null;
|
|
|
|
|
+
|
|
|
|
|
+ if (bindList.size() == 1) {
|
|
|
|
|
+ // 只绑定了一个销售,直接使用
|
|
|
|
|
+ FsUserCompanyUser bind = bindList.get(0);
|
|
|
|
|
+ bindCompanyId = bind.getCompanyId();
|
|
|
|
|
+ bindCompanyUserId = bind.getCompanyUserId();
|
|
|
|
|
+ log.info("商城订单归属:用户{}只绑定1个销售,直接绑定,companyId={},companyUserId={},订单号:{}",
|
|
|
|
|
+ userId, bindCompanyId, bindCompanyUserId, storeOrder.getOrderCode());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 绑定了多个销售,查询最近看课记录
|
|
|
|
|
+ FsCourseWatchLog latestLog = fsCourseWatchLogMapper.selectLatestWatchLogByUserId(userId);
|
|
|
|
|
+ if (latestLog != null && latestLog.getCompanyUserId() != null) {
|
|
|
|
|
+ bindCompanyId = latestLog.getCompanyId();
|
|
|
|
|
+ bindCompanyUserId = latestLog.getCompanyUserId();
|
|
|
|
|
+ log.info("商城订单归属:用户{}绑定多个销售,通过最近看课记录绑定,companyId={},companyUserId={},订单号:{}",
|
|
|
|
|
+ userId, bindCompanyId, bindCompanyUserId, storeOrder.getOrderCode());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ log.info("商城订单归属:用户{}绑定多个销售但无看课记录,不绑定归属,订单号:{}", userId, storeOrder.getOrderCode());
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 绑定归属到订单
|
|
|
|
|
+ if (bindCompanyId != null || bindCompanyUserId != null) {
|
|
|
|
|
+ storeOrder.setCompanyId(bindCompanyId);
|
|
|
|
|
+ storeOrder.setCompanyUserId(bindCompanyUserId);
|
|
|
|
|
+ log.info("商城订单归属绑定成功,订单号:{},companyId={},companyUserId={}",
|
|
|
|
|
+ storeOrder.getOrderCode(), bindCompanyId, bindCompanyUserId);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|