|
|
@@ -21,7 +21,6 @@ import com.fs.his.domain.FsPayConfig;
|
|
|
import com.fs.his.domain.FsUser;
|
|
|
import com.fs.his.domain.MerchantAppConfig;
|
|
|
import com.fs.his.domain.FsUserWx;
|
|
|
-import com.fs.his.param.FsIntegralOrderDoPayParam;
|
|
|
import com.fs.his.mapper.FsUserWxMapper;
|
|
|
import com.fs.his.mapper.MerchantAppConfigMapper;
|
|
|
import com.fs.his.service.IFsUserService;
|
|
|
@@ -32,6 +31,7 @@ import com.fs.hisStore.domain.FsStoreOrderPick;
|
|
|
import com.fs.hisStore.domain.FsStoreOrderScrm;
|
|
|
import com.fs.hisStore.domain.FsStorePaymentScrm;
|
|
|
import com.fs.hisStore.domain.FsStoreProductScrm;
|
|
|
+import com.fs.hisStore.domain.FsStoreRedeemedRecord;
|
|
|
import com.fs.hisStore.domain.FsUserAddressScrm;
|
|
|
import com.fs.hisStore.domain.FsUserScrm;
|
|
|
import com.fs.hisStore.mapper.FsStorePaymentScrmMapper;
|
|
|
@@ -43,11 +43,12 @@ import com.fs.hisStore.param.FsStoreOrderPickAddParam;
|
|
|
import com.fs.hisStore.param.FsStoreOrderPickComputeParam;
|
|
|
import com.fs.hisStore.param.FsStoreOrderPickPayParam;
|
|
|
import com.fs.hisStore.param.FsStoreOrderPickPaymentParam;
|
|
|
+import com.fs.hisStore.param.FsStoreOrderPickRedeemParam;
|
|
|
import com.fs.hisStore.service.IFsStoreOrderPickService;
|
|
|
+import com.fs.hisStore.service.IFsStoreRedeemedRecordService;
|
|
|
import com.fs.hisStore.service.IFsStoreOrderScrmService;
|
|
|
import com.fs.hisStore.service.IFsStoreProductScrmService;
|
|
|
import com.fs.hisStore.service.IFsUserScrmService;
|
|
|
-import com.fs.hisStore.vo.FSUserVO;
|
|
|
import com.fs.hisStore.vo.FsStoreOrderItemVO;
|
|
|
import com.fs.course.domain.FsCoursePlaySourceConfig;
|
|
|
import com.fs.course.mapper.FsCoursePlaySourceConfigMapper;
|
|
|
@@ -122,6 +123,8 @@ public class FsStoreOrderPickServiceImpl extends ServiceImpl<FsStoreOrderPickMap
|
|
|
private IFsUserService userService;
|
|
|
@Autowired
|
|
|
private WxPayProperties wxPayProperties;
|
|
|
+ @Autowired
|
|
|
+ private IFsStoreRedeemedRecordService fsStoreRedeemedRecordService;
|
|
|
|
|
|
/**
|
|
|
* 查询自提商品订单
|
|
|
@@ -202,7 +205,7 @@ public class FsStoreOrderPickServiceImpl extends ServiceImpl<FsStoreOrderPickMap
|
|
|
return R.error("用户不存在");
|
|
|
}
|
|
|
FsStoreProductScrm product = fsStoreProductScrmService.selectFsStoreProductById(param.getProductId());
|
|
|
- if (product == null || Integer.valueOf(1).equals(product.getIsDel())) {
|
|
|
+ if (product == null || 1 == product.getIsDel()) {
|
|
|
return R.error("商品不存在");
|
|
|
}
|
|
|
String orderCode = OrderCodeUtils.getOrderSn();
|
|
|
@@ -229,9 +232,9 @@ public class FsStoreOrderPickServiceImpl extends ServiceImpl<FsStoreOrderPickMap
|
|
|
order.setIsDel(0);
|
|
|
order.setIsSysDel(0);
|
|
|
Integer productShippingType = product.getShippingType();
|
|
|
- if (Integer.valueOf(1).equals(productShippingType)) {
|
|
|
+ if (1 == productShippingType) {
|
|
|
order.setShippingType(2);
|
|
|
- } else if (Integer.valueOf(2).equals(productShippingType)) {
|
|
|
+ } else if (2 == productShippingType) {
|
|
|
order.setShippingType(1);
|
|
|
} else {
|
|
|
order.setShippingType(2);
|
|
|
@@ -283,7 +286,7 @@ public class FsStoreOrderPickServiceImpl extends ServiceImpl<FsStoreOrderPickMap
|
|
|
return R.error("订单号不能为空");
|
|
|
}
|
|
|
FsStoreOrderScrm order = fsStoreOrderScrmService.selectFsStoreOrderById(param.getOrderId());
|
|
|
- if (order == null || !userId.equals(order.getUserId()) || !Integer.valueOf(1).equals(order.getIsPickup())) {
|
|
|
+ if (order == null || !userId.equals(order.getUserId()) || 1 != order.getIsPickup()) {
|
|
|
return R.error("订单不存在");
|
|
|
}
|
|
|
Map<String, Object> moneys = computeOrderMoney(order.getTotalPrice(), param);
|
|
|
@@ -322,6 +325,7 @@ public class FsStoreOrderPickServiceImpl extends ServiceImpl<FsStoreOrderPickMap
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public R payFsStoreOrderPick(Long userId, FsStoreOrderPickPayParam param) {
|
|
|
if (param == null || param.getOrderId() == null) {
|
|
|
return R.error("订单号不能为空");
|
|
|
@@ -330,7 +334,7 @@ public class FsStoreOrderPickServiceImpl extends ServiceImpl<FsStoreOrderPickMap
|
|
|
return R.error("非法操作");
|
|
|
}
|
|
|
FsStoreOrderScrm order = fsStoreOrderScrmService.selectFsStoreOrderById(param.getOrderId());
|
|
|
- if (order == null || !userId.equals(order.getUserId()) || !Integer.valueOf(1).equals(order.getIsPickup())) {
|
|
|
+ if (order == null || !userId.equals(order.getUserId()) || 1 != order.getIsPickup()) {
|
|
|
return R.error("订单不存在");
|
|
|
}
|
|
|
// 状态必须要是待支付
|
|
|
@@ -374,7 +378,7 @@ public class FsStoreOrderPickServiceImpl extends ServiceImpl<FsStoreOrderPickMap
|
|
|
return R.error("参数错误");
|
|
|
}
|
|
|
FsStoreOrderScrm order = fsStoreOrderScrmService.selectFsStoreOrderById(param.getOrderId());
|
|
|
- if (order == null || !param.getUserId().equals(order.getUserId()) || !Integer.valueOf(1).equals(order.getIsPickup())) {
|
|
|
+ if (order == null || !param.getUserId().equals(order.getUserId()) || 1 != order.getIsPickup()) {
|
|
|
return R.error("订单不存在");
|
|
|
}
|
|
|
if (!Integer.valueOf(0).equals(order.getStatus())) {
|
|
|
@@ -613,19 +617,90 @@ public class FsStoreOrderPickServiceImpl extends ServiceImpl<FsStoreOrderPickMap
|
|
|
@Override
|
|
|
public R getFsStoreOrderPickDetail(Long userId, Long orderId) {
|
|
|
FsStoreOrderScrm order = fsStoreOrderScrmService.selectFsStoreOrderById(orderId);
|
|
|
- if (order == null || !userId.equals(order.getUserId()) || !Integer.valueOf(1).equals(order.getIsPickup())) {
|
|
|
+ if (order == null || !userId.equals(order.getUserId()) || 1 != order.getIsPickup()) {
|
|
|
return R.error("订单不存在");
|
|
|
}
|
|
|
List<FsStoreOrderItemVO> items = fsStoreOrderItemScrmMapper.selectFsStoreOrderItemListByOrderId(orderId);
|
|
|
return R.ok().put("order", order).put("items", items);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public R redeemFsStoreOrderPick(Long userId, FsStoreOrderPickRedeemParam param) {
|
|
|
+ FsStoreOrderScrm order = fsStoreOrderScrmService.selectFsStoreOrderById(param.getOrderId());
|
|
|
+ if (order == null || 1 != order.getIsPickup()) {
|
|
|
+ return R.error("订单不存在");
|
|
|
+ }
|
|
|
+ if (1 != order.getRedeemedStatus()) {
|
|
|
+ return R.error("非法操作");
|
|
|
+ }
|
|
|
+ FsStoreOrderItemScrm itemQuery = new FsStoreOrderItemScrm();
|
|
|
+ itemQuery.setOrderId(order.getId());
|
|
|
+ List<FsStoreOrderItemScrm> orderItems = fsStoreOrderItemScrmMapper.selectFsStoreOrderItemList(itemQuery);
|
|
|
+ if (orderItems == null || orderItems.isEmpty()) {
|
|
|
+ return R.ok().put("data", false);
|
|
|
+ }
|
|
|
+ for (FsStoreOrderItemScrm orderItem : orderItems) {
|
|
|
+ FsStoreProductScrm product = fsStoreProductScrmService.selectFsStoreProductById(orderItem.getProductId());
|
|
|
+ if (product == null || 1 != product.getShippingType()) {
|
|
|
+ return R.error("非自提订单不允许核销");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Date now = DateUtils.getNowDate();
|
|
|
+ FsStoreRedeemedRecord record = new FsStoreRedeemedRecord();
|
|
|
+ record.setUserId(order.getUserId());
|
|
|
+ record.setOrderId(order.getId());
|
|
|
+ record.setOrderCode(order.getOrderCode());
|
|
|
+ record.setRedeemedTime(now);
|
|
|
+ record.setCompanyUserId(order.getCompanyUserId());
|
|
|
+ record.setCompanyId(order.getCompanyId());
|
|
|
+ record.setRedeemedUserId(param.getRedeemedUserId().toString());
|
|
|
+ record.setStatus(1);
|
|
|
+ int insertRows = fsStoreRedeemedRecordService.insertFsStoreRedeemedRecord(record);
|
|
|
+ if (insertRows <= 0) {
|
|
|
+ return R.error("核销失败");
|
|
|
+ }
|
|
|
+ FsStoreOrderScrm updateOrder = new FsStoreOrderScrm();
|
|
|
+ updateOrder.setId(order.getId());
|
|
|
+ updateOrder.setRedeemedTime(now);
|
|
|
+ updateOrder.setRedeemedStatus(2);
|
|
|
+ updateOrder.setRedeemedId(record.getId());
|
|
|
+ updateOrder.setUpdateTime(now);
|
|
|
+ fsStoreOrderScrmMapper.updateFsStoreOrder(updateOrder);
|
|
|
+ return R.ok("核销成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R cancelRedeemOrderPick(Long userId, FsStoreOrderPickRedeemParam param) {
|
|
|
+ FsStoreOrderScrm order = fsStoreOrderScrmService.selectFsStoreOrderById(param.getOrderId());
|
|
|
+ if (order == null || 1 != order.getIsPickup()) {
|
|
|
+ return R.error("订单不存在");
|
|
|
+ }
|
|
|
+ if (3 == order.getRedeemedStatus()) {
|
|
|
+ return R.error("订单已取消核销,请勿重复操作");
|
|
|
+ }
|
|
|
+ if (1 != order.getRedeemedStatus()) {
|
|
|
+ return R.error("当前订单状态非待核销");
|
|
|
+ }
|
|
|
+ FsStoreOrderScrm updateOrder = new FsStoreOrderScrm();
|
|
|
+ updateOrder.setId(order.getId());
|
|
|
+ updateOrder.setRedeemedStatus(3);
|
|
|
+ updateOrder.setCancelExplain(param.getCancelExplain());
|
|
|
+ updateOrder.setCancelTime(DateUtils.getNowDate());
|
|
|
+ updateOrder.setUpdateTime(DateUtils.getNowDate());
|
|
|
+ int updateRows = fsStoreOrderScrmMapper.updateFsStoreOrder(updateOrder);
|
|
|
+ if (updateRows <= 0) {
|
|
|
+ return R.error("取消核销失败");
|
|
|
+ }
|
|
|
+ return R.ok("取消核销成功");
|
|
|
+ }
|
|
|
+
|
|
|
private R buildPickOrderPreview(FsStoreOrderPickAddParam param) {
|
|
|
if (param == null || param.getUserId() == null || param.getProductId() == null) {
|
|
|
return R.error("参数错误");
|
|
|
}
|
|
|
FsStoreProductScrm product = fsStoreProductScrmService.selectFsStoreProductById(param.getProductId());
|
|
|
- if (product == null || Integer.valueOf(1).equals(product.getIsDel())) {
|
|
|
+ if (product == null || 1 == product.getIsDel()) {
|
|
|
return R.error("商品不存在");
|
|
|
}
|
|
|
BigDecimal price = product.getPrice() == null ? BigDecimal.ZERO : product.getPrice();
|