|
|
@@ -172,6 +172,8 @@ import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+import static com.fs.common.utils.SecurityUtils.getUserId;
|
|
|
+import static com.fs.common.utils.SecurityUtils.getUsername;
|
|
|
import static com.fs.his.utils.PhoneUtil.decryptPhone;
|
|
|
import static com.fs.hisStore.constants.StoreConstants.DELIVERY;
|
|
|
|
|
|
@@ -1109,6 +1111,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
FsStoreOrderItemScrm item = new FsStoreOrderItemScrm();
|
|
|
item.setOrderId(storeOrder.getId());
|
|
|
item.setOrderCode(orderSn);
|
|
|
+ item.setProductAttrValueId(vo.getProductAttrValueId());
|
|
|
item.setCartId(vo.getId());
|
|
|
item.setProductId(vo.getProductId());
|
|
|
item.setJsonInfo(JSONUtil.toJsonStr(fsStoreCartDTO));
|
|
|
@@ -1848,6 +1851,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
item.setOrderCode(orderSn);
|
|
|
item.setCartId(vo.getId());
|
|
|
item.setProductId(vo.getProductId());
|
|
|
+ item.setProductAttrValueId(vo.getProductAttrValueId());
|
|
|
item.setJsonInfo(JSONUtil.toJsonStr(fsStoreCartDTO));
|
|
|
item.setNum(vo.getCartNum());
|
|
|
item.setIsAfterSales(0);
|
|
|
@@ -5917,4 +5921,112 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
}
|
|
|
return payOrderParam;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R createAddress(String orderKey, FsUserAddressScrm fsUserAddressScrm) {
|
|
|
+ fsUserAddressScrm.setIsDefault(1);
|
|
|
+// fsUserAddressScrm.setCreateBy(getUsername());
|
|
|
+ fsUserAddressScrm.setCreateTime(new Date());
|
|
|
+ redisCache.setCacheObject("createAddressKey:" + orderKey, fsUserAddressScrm, 24, TimeUnit.HOURS);
|
|
|
+ return R.ok().put("orderKey",orderKey).put("fsUserAddressScrm",fsUserAddressScrm);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R getAddress(String orderKey) {
|
|
|
+ // 参数校验
|
|
|
+ if (orderKey == null || orderKey.isEmpty()) {
|
|
|
+ return R.error("订单标识不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 从Redis获取缓存对象
|
|
|
+ String cacheKey = "createAddressKey:" + orderKey;
|
|
|
+ FsUserAddressScrm fsUserAddressScrm = redisCache.getCacheObject(cacheKey);
|
|
|
+
|
|
|
+ // 空值检查
|
|
|
+ if (ObjectUtil.isNotEmpty(fsUserAddressScrm)) {
|
|
|
+ return R.ok().put("data", fsUserAddressScrm);
|
|
|
+ } else {
|
|
|
+ return R.error("地址信息不存在或已过期,请重新创建");
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ // 记录异常日志
|
|
|
+ log.error("获取地址信息异常, orderKey: {}", orderKey, e);
|
|
|
+ return R.error("系统异常,请稍后重试");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R updateAddress(String orderKey, Long userId) {
|
|
|
+ // 参数校验
|
|
|
+ if (orderKey == null || orderKey.isEmpty() || userId == null) {
|
|
|
+ return R.error("参数不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 更新用户地址
|
|
|
+ int update = userAddressMapper.updateByUserId(userId);
|
|
|
+
|
|
|
+ if (update > 0) {
|
|
|
+ // 从Redis获取缓存对象
|
|
|
+ String cacheKey = "createAddressKey:" + orderKey;
|
|
|
+ FsUserAddressScrm fsUserAddressScrm = redisCache.getCacheObject(cacheKey);
|
|
|
+
|
|
|
+ // 空值检查
|
|
|
+ if (fsUserAddressScrm == null) {
|
|
|
+ return R.error("缓存数据不存在或已过期");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置属性并插入
|
|
|
+ fsUserAddressScrm.setUserId(userId);
|
|
|
+
|
|
|
+ int insertResult = userAddressMapper.insertFsUserAddress(fsUserAddressScrm);
|
|
|
+
|
|
|
+ if (insertResult > 0) {
|
|
|
+ // 可选: 插入成功后删除缓存
|
|
|
+ // redisCache.deleteObject(cacheKey);
|
|
|
+ return R.ok("地址更新成功").put("data",fsUserAddressScrm);
|
|
|
+ } else {
|
|
|
+ return R.error("地址插入失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return R.error("更新失败");
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ // 记录异常日志
|
|
|
+ log.error("更新地址异常, orderKey: {}, userId: {}", orderKey, userId, e);
|
|
|
+ return R.error("系统异常,请稍后重试");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询订单数量统计
|
|
|
+ * @param type 类型:1-仅查询待发货和待收货;其他-查询全部状态
|
|
|
+ * @param userId 用户ID
|
|
|
+ * @return 订单统计结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public R selectOrderCount(Integer type, Long userId) {
|
|
|
+ OrderCountVO vo = new OrderCountVO();
|
|
|
+
|
|
|
+ if (ObjectUtil.isNotEmpty(type) && type.equals(1)) {
|
|
|
+ // 查询待发货和待收货
|
|
|
+ vo.setUnshippedCount(fsStoreOrderMapper.selectFsStoreOrderCount(userId, 1));
|
|
|
+ vo.setUnreceivedCount(fsStoreOrderMapper.selectFsStoreOrderCount(userId, 2));
|
|
|
+ } else {
|
|
|
+ // 查询全部订单状态统计
|
|
|
+ vo.setUnpaidCount(fsStoreOrderMapper.selectFsStoreOrderCount(userId, 0));
|
|
|
+ vo.setUnshippedCount(fsStoreOrderMapper.selectFsStoreOrderCount(userId, 1));
|
|
|
+ vo.setUnreceivedCount(fsStoreOrderMapper.selectFsStoreOrderCount(userId, 2));
|
|
|
+ vo.setCompletedCount(fsStoreOrderMapper.selectFsStoreOrderCount(userId, 3));
|
|
|
+ vo.setRefundingCount(fsStoreOrderMapper.selectFsStoreOrderCount(userId, -1));
|
|
|
+ vo.setRefundedCount(fsStoreOrderMapper.selectFsStoreOrderCount(userId, -2));
|
|
|
+ }
|
|
|
+ return R.ok().put("data",vo);
|
|
|
+ }
|
|
|
+
|
|
|
}
|