|
@@ -968,6 +968,7 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
|
|
|
newOrderDao.insertShortLink(markId, shortLink, url);
|
|
|
return shortLink;
|
|
|
}
|
|
|
+
|
|
|
@Transactional(readOnly = false)
|
|
|
public boolean getSendSms(int markId, String mobile, String content) throws Exception {
|
|
|
String config = Global.getConfig("cm.config");
|
|
@@ -1456,8 +1457,8 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
|
|
|
*/
|
|
|
if ((1161 != shopOrder.getShopID() && 2 != shopOrder.getOrderType() && !flag &&
|
|
|
(!"E1807059160".equals(shopOrder.getSplitCode()) && null != discernPayWay && 1 != discernPayWay))) {
|
|
|
- // 订单下线收款, 付款状态与收款状态同步显示
|
|
|
- shopOrder.setPayStatus(shopOrder.getReceiptStatus());
|
|
|
+ // 订单下线收款, 付款状态与收款状态同步显示
|
|
|
+ shopOrder.setPayStatus(shopOrder.getReceiptStatus());
|
|
|
}
|
|
|
// 订单已收款才会出现抹平或者多收退余额,(已收再退款或者撤销退款订单即使存在抹平也需要当未抹平重新计算付款)
|
|
|
String receiptStatus = shopOrder.getReceiptStatus();
|
|
@@ -1774,25 +1775,6 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
|
|
|
int userBeans = user.getUserBeans() + order.getUserBeans();
|
|
|
cmUserDao.updateUserBeans(order.getUserID(), userBeans);
|
|
|
}
|
|
|
-
|
|
|
-// if (order.getPayTotalFee() != null && order.getPayTotalFee() < 1000) {
|
|
|
-// //查本单是否扣豆子,有就返回
|
|
|
-// UserBeansHistory bean = newCmClubDao.findLowOrder(order.getOrderID());
|
|
|
-// if (bean != null) {
|
|
|
-// //有扣豆子记录
|
|
|
-// UserBeansHistory beansHistory = new UserBeansHistory();
|
|
|
-// beansHistory.setUserId(order.getUserID());
|
|
|
-// beansHistory.setOrderId(order.getOrderID());
|
|
|
-// beansHistory.setBeansType(16);
|
|
|
-// beansHistory.setType(1);
|
|
|
-// beansHistory.setNum(500);
|
|
|
-// beansHistory.setPushStatus(0);
|
|
|
-// beansHistory.setAddTime(new Date());
|
|
|
-// newCmClubDao.insertBeansHistory(beansHistory);
|
|
|
-// int beans = cmUserDao.findUserBeans(order.getUserID()) + 500;
|
|
|
-// cmUserDao.updateUserBeans(order.getUserID(), beans);
|
|
|
-// }
|
|
|
-// }
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
String current = dateFormat.format(new Date());
|
|
|
MessageCenter messageCenter = new MessageCenter();
|
|
@@ -2887,4 +2869,170 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
+ public void cancelShopOrder(NewShopOrder shopOrder) {
|
|
|
+ //余额退回原账户
|
|
|
+ CmUser user = cmUserDao.get(order.getUserID().toString());
|
|
|
+ if (order.getBalancePayFee() > 0) {
|
|
|
+ setBalance(user, order.getBalancePayFee(), order);
|
|
|
+ //取消收支记录
|
|
|
+ CmUserBalanceRecord cmUserBalanceRecord = new CmUserBalanceRecord();
|
|
|
+ cmUserBalanceRecord.setUserId(order.getUserID());
|
|
|
+ cmUserBalanceRecord.setOrderId(order.getOrderID());
|
|
|
+ cmUserBalanceRecord.setRemark("取消订单,余额记录无效-后台");
|
|
|
+ cmUserBalanceRecord.setDelFlag("1");
|
|
|
+ cmUserBalanceRecordService.updateBalanceRecord(cmUserBalanceRecord);
|
|
|
+ }
|
|
|
+ order.setStatus("6");//订单状态变成交易关闭 6
|
|
|
+ order.setCloseReason("后台手动关闭");// 订单取消原因
|
|
|
+ newOrderDao.updateStatus(order);
|
|
|
+ //二手订单取消订单,标记未售
|
|
|
+ if ("1".equals(order.getSecondHandOrderFlag())) {
|
|
|
+ List<NewOrderProduct> orderProducts = newOrderProductDao.findListByOrderID(orderID);
|
|
|
+ for (NewOrderProduct orderProduct : orderProducts) {
|
|
|
+ cmSecondHandDetailDao.updatSecondHnadBySold(orderProduct.getProductID());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //采美豆退回
|
|
|
+ if (order.getUserBeans() != null && order.getUserBeans() > 0) {
|
|
|
+ UserBeansHistory beansHistory = new UserBeansHistory();
|
|
|
+ beansHistory.setUserId(order.getUserID());
|
|
|
+ beansHistory.setOrderId(order.getOrderID());
|
|
|
+ beansHistory.setBeansType(9);
|
|
|
+ beansHistory.setType(1);
|
|
|
+ beansHistory.setNum(order.getUserBeans());
|
|
|
+ beansHistory.setPushStatus(0);
|
|
|
+ beansHistory.setAddTime(new Date());
|
|
|
+ newCmClubDao.insertBeansHistory(beansHistory);
|
|
|
+ int userBeans = user.getUserBeans() + order.getUserBeans();
|
|
|
+ cmUserDao.updateUserBeans(order.getUserID(), userBeans);
|
|
|
+ }
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String current = dateFormat.format(new Date());
|
|
|
+ MessageCenter messageCenter = new MessageCenter();
|
|
|
+ messageCenter.setShopId(null);
|
|
|
+ messageCenter.setClubId(order.getClubID());
|
|
|
+ messageCenter.setUserType(1);
|
|
|
+ messageCenter.setMessageType(1);
|
|
|
+ messageCenter.setOrderMessageType(4);
|
|
|
+ messageCenter.setContent("您的订单已成功取消!");
|
|
|
+ messageCenter.setOrderId(orderID);
|
|
|
+ messageCenter.setTime(current);
|
|
|
+ messageCenterDao.addMessageCenter(messageCenter);
|
|
|
+
|
|
|
+ //优惠券退回
|
|
|
+ if (order.getCouponAmount() > 0 && !"0".equals(order.getStatus())) {
|
|
|
+ CmCouponOrderRecord couponRecord = newOrderDao.findOrderCouponRecord(order.getOrderID());
|
|
|
+ if (couponRecord != null) {
|
|
|
+ CmCouponClub couponClub = cmCouponClubDao.get(couponRecord.getClubCouponId().toString());
|
|
|
+ couponClub.setOrderId(null);
|
|
|
+ couponClub.setReturnedId(0);
|
|
|
+ couponClub.setSource("3");
|
|
|
+ couponClub.setStatus("1");
|
|
|
+ couponClub.setCreateDate(new Date());
|
|
|
+ couponClub.setUseDate(null);
|
|
|
+ couponClub.setDelFlag("0");
|
|
|
+ cmCouponClubDao.insert(couponClub);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ Date date = new Date();
|
|
|
+ String curDateStr = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(date);
|
|
|
+ String note = "【取消订单】";
|
|
|
+ // 余额退回原账户
|
|
|
+ if (null != shopOrder.getAccountAmount() && MathUtil.compare(shopOrder.getAccountAmount(), 0) > 0) {
|
|
|
+ CmUser user = cmUserDao.get(shopOrder.getUserID().toString());
|
|
|
+ double ableUserMoney = user.getAbleUserMoney();
|
|
|
+ double updateMoney = MathUtil.add(ableUserMoney, shopOrder.getAccountAmount()).doubleValue();
|
|
|
+ // 退回用户可用余额
|
|
|
+ orderClubMapper.updateAbleUserMoneyByUserId(updateMoney, shopOrder.getUserId());
|
|
|
+ log.info(note + ">>>>>>>>>>>可用余额退回原账户(update[user(ableUserMoney)])userId:" + shopOrder.getUserId() + ",shopOrderId:" + shopOrderId);
|
|
|
+ // 取消收支记录
|
|
|
+ BalanceRecordPo balanceRecord = new BalanceRecordPo();
|
|
|
+ balanceRecord.setUserId(shopOrder.getUserId());
|
|
|
+ balanceRecord.setShopOrderId(shopOrderId);
|
|
|
+ balanceRecord.setRemark("取消订单,余额记录无效");
|
|
|
+ balanceRecord.setDelFlag(1);
|
|
|
+ // 取消 余额收支记录
|
|
|
+ orderClubMapper.cancelBalanceRecord(balanceRecord);
|
|
|
+ log.info(note + ">>>>>>>>>>>>取消余额收支记录(update[cm_user_balance_record])shopOrderId:" + shopOrderId);
|
|
|
+ }
|
|
|
+ shopOrder.setStatus(4);
|
|
|
+ // 取消 订单
|
|
|
+ orderClubMapper.cancelMainShopOrder(shopOrder);
|
|
|
+ //二手订单取消订单, 二手商品标记未售
|
|
|
+ if (1 == shopOrder.getSecondHandOrderFlag()) {
|
|
|
+ List<OrderProductPo> orderProducts = orderClubMapper.getShopOrderProductList(shopOrderId);
|
|
|
+ orderProducts.forEach(product -> {
|
|
|
+ // 是否二手商品
|
|
|
+ boolean secondFlag = false;
|
|
|
+ if (null != product.getProductCategory() && 2 == product.getProductCategory()) {
|
|
|
+ secondFlag = true;
|
|
|
+ }
|
|
|
+ // 二手仪器标记未售
|
|
|
+ if (secondFlag) {
|
|
|
+ orderClubMapper.updateSecondStatus(product.getProductId(), 0);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 子订单状态
|
|
|
+ List<Integer> shopOrderStatus = orderClubMapper.getShopOrderStatus(shopOrder.getOrderId());
|
|
|
+ boolean flag = false;
|
|
|
+ if (shopOrderStatus.stream().allMatch(s -> s == 4)) {
|
|
|
+ flag = true;
|
|
|
+ }
|
|
|
+ // 退回 采美豆
|
|
|
+ if (null != shopOrder.getUserBeans() && shopOrder.getUserBeans() > 0 && flag) {
|
|
|
+ UserBeansHistoryPo beansHistory = new UserBeansHistoryPo();
|
|
|
+ beansHistory.setUserId(shopOrder.getUserId());
|
|
|
+ beansHistory.setOrderId(shopOrder.getOrderId());
|
|
|
+ beansHistory.setBeansType(9);
|
|
|
+ beansHistory.setType(1);
|
|
|
+ beansHistory.setNum(shopOrder.getUserBeans());
|
|
|
+ beansHistory.setPushStatus(0);
|
|
|
+ beansHistory.setAddTime(date);
|
|
|
+ beansHistory.setDelFlag(0);
|
|
|
+ // 用户采美豆
|
|
|
+ Integer userBeans = baseMapper.getUserBeans(shopOrder.getUserId());
|
|
|
+ // 更新用户剩余采美豆数量
|
|
|
+ int beans = userBeans + beansHistory.getNum();
|
|
|
+ productService.updateUserBeans(beansHistory, beans, note);
|
|
|
+ }
|
|
|
+ // 客服确认注册机构,一天内取消有效
|
|
|
+ Integer clubStatus = baseMapper.getClubStatus(shopOrder.getUserId());
|
|
|
+ if (null != clubStatus && 94 == clubStatus) {
|
|
|
+ // 已冻结(客服确认机构)
|
|
|
+ // 查询最后的确认时间
|
|
|
+ Date confirmTime = baseMapper.getClubConfirmTime(shopOrder.getUserId());
|
|
|
+ if (confirmTime != null) {
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(confirmTime);
|
|
|
+ calendar.add(Calendar.DATE, 1);
|
|
|
+ if (calendar.getTime().compareTo(new Date()) > 0) {
|
|
|
+ // 机构状态修改为:已确认(客服确认机构)
|
|
|
+ baseMapper.updateUserClubStatus(93, shopOrder.getUserId());
|
|
|
+ baseMapper.updateClubStatus(93, shopOrder.getUserId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //优惠券退回
|
|
|
+ if (MathUtil.compare(shopOrder.getCouponAmount(), 0) > 0) {
|
|
|
+ CouponOrderRecordPo couponRecord = orderClubMapper.getOrderCouponRecord(shopOrder.getOrderId(), shopOrder.getCouponClubId());
|
|
|
+ if (couponRecord != null) {
|
|
|
+ orderClubMapper.deleteCouponClubById(couponRecord.getClubCouponId());
|
|
|
+ CouponClubPo couponClub = orderClubMapper.getCouponClubById(couponRecord.getClubCouponId());
|
|
|
+ couponClub.setOrderId(null);
|
|
|
+ couponClub.setReturnedId(0);
|
|
|
+ couponClub.setSource(3);
|
|
|
+ couponClub.setStatus("1");
|
|
|
+ couponClub.setCreateDate(new Date());
|
|
|
+ couponClub.setUseDate(null);
|
|
|
+ couponClub.setDelFlag("0");
|
|
|
+ orderClubMapper.insertCouponClub(couponClub);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|