| | |
| | | orderNodeBuilder.append("-结束处理活动规则"); |
| | | |
| | | //非主线业务 |
| | | /** |
| | | * 处理老带新(禅道为准,禅道号176) |
| | | * 1.准会员、普卡、银卡: |
| | | * 邀请人增值金百分比:8% |
| | | * 被邀请人增值金百分比:2% |
| | | * 2.金卡、钻卡、黑卡: |
| | | * 邀请人增值金百分比:10% |
| | | * 被邀请人增值金百分比:5% |
| | | */ |
| | | JSONObject commissionObject =new JSONObject(); |
| | | if(ordersTotal.getOrderInfo().getIsOldBringNew() !=null && ordersTotal.getOrderInfo().getIsOldBringNew()==BaseEntity.YES){ |
| | | //这种写法错误,会报 异常:Transaction rolled back because it has been marked as rollback-only |
| | | // try { |
| | | // orderNodeBuilder.append("-开始处理老带新"); |
| | | // commissionObject = OrderPayMoneyUtil.handPayOldNew(ordersTotal, user, hisPayList, commonService); |
| | | // orderNodeBuilder.append("-结束处理老带新"); |
| | | // }catch (Exception e){ |
| | | // String snapshot="处理老带新失败"; |
| | | // orderNodeBuilder.append("-处理老带新失败,异常原因:"+e.getMessage()); |
| | | // logger.error("处理老带新失败:" + e.getMessage()); |
| | | // //发送企业微信通知给工作人员 |
| | | // SendNoticeUtil.failOrderSendNotice(ordersTotal,e.getMessage(),snapshot,commonService,customParameter); |
| | | // message=e.getMessage(); |
| | | // } |
| | | //解决以上报错 |
| | | try { |
| | | /** |
| | | * 异常: |
| | | * Transaction rolled back because it has been marked as rollback-only |
| | | * 开启线程处理老带新,是因为调用用户操作资金方法报错了,会标记事务需要会滚导致主业务进行会滚问题 |
| | | * 原因:主业务有事务,操作用户资金也有事务,后者事务继承了前者事务,所以后者事务回滚会标记,导致主业务事务也会回滚 |
| | | * 解决办法: |
| | | * 1、修改操作用户资金事务隔离级别,不使用默认的事务隔离级别,采用有事务则开启新事物隔离级别 |
| | | * 2、开启线程进行处理 |
| | | * 3、贴异步注解方式(@Async) |
| | | */ |
| | | OrdersTotal ordersTotalSync = ordersTotal; |
| | | JSONArray hisPayListSync = hisPayList; |
| | | orderNodeBuilder.append("-开始处理老带新"); |
| | | CompletableFuture<JSONObject> commissionObjectFuture = CompletableFuture.supplyAsync(() -> { |
| | | return OrderPayMoneyUtil.handPayOldNew(ordersTotalSync, user, hisPayListSync, commonService); |
| | | }, threadPool); |
| | | // get 线程返回结果 |
| | | commissionObject = commissionObjectFuture.get(); |
| | | // orderService.handPayOldNew(ordersTotal,user,hisPayList,commonService); |
| | | |
| | | orderNodeBuilder.append("-结束处理老带新"); |
| | | }catch (Exception e){ |
| | | String snapshot="处理老带新失败"; |
| | | orderNodeBuilder.append("-处理老带新失败,异常原因:"+e.getMessage()); |
| | | logger.error("处理老带新失败:" + e.getMessage()); |
| | | //发送企业微信通知给工作人员 |
| | | SendNoticeUtil.failOrderSendNotice(ordersTotal,e.getMessage(),snapshot,commonService,customParameter); |
| | | message=e.getMessage(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 用户升降级(调用航爷) 金额=用户支付的实付现金金额(不包含储值金) |
| | |
| | | }catch (Exception e){ |
| | | logger.info("结账成功发送公众号通知给用户异常 -异步:{}",e.getMessage(),e); |
| | | } |
| | | //需求: 1.HIS助手结账成功:要通知客户所属顾问,发送企业微信通知 ,如果没有所属顾问发送给门店运营客服(三少说目前不处理crm已处理) -异步 |
| | | try { |
| | | sendUserConsultant(ordersTotal.getUserId(),ordersTotal.getOrderNo(),ordersTotal.getId(),commissionObject,commonService); |
| | | }catch (Exception e){ |
| | | logger.info("要通知客户所属顾问,发送企业微信通知异常 -异步:{}",e.getMessage(),e); |
| | | } |
| | | //更新用户最后下单时间 |
| | | try { |
| | | SqlSentence sqlSentence = new SqlSentence(); |
| | | Map<String, Object> sqlValues = new HashMap<>(); |
| | | sqlValues.put("lastPayOrderTime", new Date()); |
| | | sqlValues.put("editTime", new Date()); |
| | | sqlValues.put("isLoss", BaseEntity.NO); |
| | | sqlValues.put("isDel", BaseEntity.NO); |
| | | sqlValues.put("id", user.getId()); |
| | | StringBuilder sql = new StringBuilder(); |
| | | sql.append(" lastPayOrderTime=#{m.lastPayOrderTime},editTime=#{m.editTime},isLoss=#{m.isLoss}"); |
| | | // 会员有消费和执行就是活跃会员 |
| | | String status = null; |
| | | if (!UserStatusConstants.USER_STATUS_NON_MEMBER.equals(user.getUserStatus())) { |
| | | status = UserStatusConstants.USER_STATUS_ACTIVE_MEMBER; |
| | | sqlValues.put("userStatus", status); |
| | | sql.append(",userStatus=#{m.userStatus}"); |
| | | } |
| | | sql.append(" WHERE id=#{m.id} AND isDel=#{m.isDel}"); |
| | | sqlSentence.sqlSentence(sql.toString(), sqlValues); |
| | | commonService.updateWhere(UserMapper.class, sqlSentence); |
| | | // 添加调整用户状态日志 调整了用户等级在写入日志 |
| | | if (!StringUtils.isEmpty(status)) { |
| | | UserStatusTool.addUserStatusLog(commonService, user, UserStatusLog.CHANGE_STATUS_TYPE_ORDER, ordersTotal.getId(), UserStatusConstants.USER_STATUS_ACTIVE_MEMBER); |
| | | } |
| | | } catch (Exception e) { |
| | | logger.info("更新用户最后下单时间,异常:{}", e.getMessage(), e); |
| | | } |
| | | |
| | | |
| | | //返回phis订单号、phis订单id |
| | | data.put("orderId",ordersTotal.getId()); |