diff --git a/hai-bweb/src/main/java/com/bweb/controller/BsIntegralRebateController.java b/hai-bweb/src/main/java/com/bweb/controller/BsIntegralRebateController.java index 4645c338..503b4e82 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/BsIntegralRebateController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/BsIntegralRebateController.java @@ -97,8 +97,7 @@ public class BsIntegralRebateController { if (integralRebate.getPercentage() == null || integralRebate.getType() == null || integralRebate.getStartTime() == null || - integralRebate.getEndTime() == null || - integralRebate.getProductId() == null + integralRebate.getEndTime() == null ) { log.error("OutRechargePriceController -> insertPrice() error!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); diff --git a/hai-order/src/main/java/com/web/controller/business/OrderMobileRechargeController.java b/hai-order/src/main/java/com/web/controller/business/OrderMobileRechargeController.java index 940470a9..5a2f6222 100644 --- a/hai-order/src/main/java/com/web/controller/business/OrderMobileRechargeController.java +++ b/hai-order/src/main/java/com/web/controller/business/OrderMobileRechargeController.java @@ -199,8 +199,10 @@ public class OrderMobileRechargeController { @ApiOperation(value = "查询话费订单详情") public ResponseData getMobileOrderDetail(@RequestParam(name = "orderNo", required = true) String orderNo) { try { - - return ResponseMsgUtil.success(outRechargeOrderService.findByOrderNo(orderNo)); + Map map = new HashMap<>(); + map.put("tradeOrder", orderService.getOrderDetailByNo(orderNo)); + map.put("mobileOrder", outRechargeOrderService.findByOrderNo(orderNo)); + return ResponseMsgUtil.success(map); } catch (Exception e) { log.error("OrderExtController -> getGasOrderDetail() error!",e); diff --git a/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java b/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java index 15dce5f5..f10e35f0 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java +++ b/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java @@ -45,6 +45,9 @@ public class HighOrderSchedule { @Resource private BsIntegralRebateService bsIntegralRebateService; + @Resource + private BsOrderRebateService bsOrderRebateService; + /** * @Author 胡锐 * @Description 取消订单 15分钟 @@ -148,6 +151,7 @@ public class HighOrderSchedule { for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { childOrder.setChildOrderStatus(3); } + highOrder.setOrderStatus(3); highOrder.setFinishTime(new Date()); highOrderService.updateOrder(highOrder); @@ -210,9 +214,11 @@ public class HighOrderSchedule { highOrderService.updateOrder(highOrder); } } - } } + + + } catch (Exception e) { log.error("HighOrderSchedule --> handleThirdOrder() error!", e); } @@ -247,10 +253,14 @@ public class HighOrderSchedule { * @Param [] * @return void */ - @Scheduled(cron="0 0/5 * * * ?") //每 5分钟执行一次 + @Scheduled(cron="0 0/10 * * * ?") //每 5分钟执行一次 public void integralRebateOrder() { + + // 查询满足初步返利条件订单 List order = highOrderService.integralRebateOrder(); for (HighOrder highOrder : order) { + + // 查询是否存在积分记录 Map map = new HashMap<>(); map.put("goldType", 1); map.put("resType", 4); @@ -259,58 +269,13 @@ public class HighOrderSchedule { List goldRecs = highGoldRecService.getGoldRec(map); + // 判断是否重复赠送积分 if (goldRecs.size() == 0) { - List childOrderList = highOrderService.getChildOrderByOrder(highOrder.getId()); - - // 查询订单来源 - JSONObject object = highOrderService.orderSource(childOrderList.get(0).getGoodsType() , childOrderList.get(0).getGoodsId(),highOrder.getOrderNo() , highOrder.getCompanyId() , 0); - - object.put("price" , highOrder.getPayRealPrice()); - object.put("userId" , highOrder.getMemId()); - object.put("orderId" , highOrder.getId()); - object.put("companyId" , highOrder.getCompanyId()); - object.put("createTime" , highOrder.getCreateTime()); - - bsIntegralRebateService.integralRebate(object); - + bsOrderRebateService.insertOrderRebate(highOrder); } - } - } - - /** - * @Author Sum1Dream - * @name integralRebateOrder.java - * @Description // 执行返利操作 - * @Date 15:13 2022/8/22 - * @Param [] - * @return void - */ - @Scheduled(cron="0 0/5 * * * ?") //每5分钟执行一次 - public void integralRebateRechargeOrder() { - List order = outRechargeOrderService.integralRebateRechargeOrder(); - for (OutRechargeOrder outRechargeOrder : order) { - Map map = new HashMap<>(); - map.put("goldType", 1); - map.put("resType", 4); - map.put("userId", outRechargeOrder.getUserId()); - map.put("resId", outRechargeOrder.getId()); - - List goldRecs = highGoldRecService.getGoldRec(map); - - if (goldRecs.size() == 0) { - // 查询订单来源 - JSONObject object = highOrderService.orderSource(20 , outRechargeOrder.getGoodsId(),outRechargeOrder.getOrderNo() , outRechargeOrder.getCompanyId() , outRechargeOrder.getOperatorType()); - - object.put("price" , outRechargeOrder.getPayRealPrice()); - object.put("userId" , outRechargeOrder.getUserId()); - object.put("orderId" , outRechargeOrder.getId()); - object.put("companyId" , outRechargeOrder.getCompanyId()); - object.put("createTime" , outRechargeOrder.getCreateTimed()); - bsIntegralRebateService.integralRechargeRebate(object); - - } } } + } diff --git a/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java b/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java index a2933725..e9791bc3 100644 --- a/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java @@ -1140,38 +1140,58 @@ public interface HighOrderMapperExt { }) List getSelfOilStationOrderList(@Param("goodsId") String goodsId); - @Select("select * from high_order where order_status = 3 and pay_type != 3 and pay_real_price > 0 and whether_rebate = false group by create_time desc;") + // todo 根据上线时间 选择时间 + @Select("select ho.* from high_order ho left join bs_order_rebate bor on ho.id = bor.order_id where bor.id is null and order_status = 3 and pay_type != 3 and pay_real_price > 0 and whether_rebate = false and ho.create_time > '2023-02-01 00:00:00' group by create_time desc;") @Results({ @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), - @Result(column="order_no", property="orderNo", jdbcType=JdbcType.VARCHAR), + @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR), + @Result(column="search_title", property="searchTitle", jdbcType=JdbcType.VARCHAR), + @Result(column="product_type", property="productType", jdbcType=JdbcType.INTEGER), + @Result(column="company_id", property="companyId", jdbcType=JdbcType.BIGINT), + @Result(column="company_name", property="companyName", jdbcType=JdbcType.VARCHAR), + @Result(column="promote_code", property="promoteCode", jdbcType=JdbcType.VARCHAR), @Result(column="mem_discount_id", property="memDiscountId", jdbcType=JdbcType.BIGINT), @Result(column="mem_discount_name", property="memDiscountName", jdbcType=JdbcType.VARCHAR), @Result(column="mem_id", property="memId", jdbcType=JdbcType.BIGINT), @Result(column="mem_name", property="memName", jdbcType=JdbcType.VARCHAR), @Result(column="mem_phone", property="memPhone", jdbcType=JdbcType.VARCHAR), - @Result(column="pay_model", property="payModel", jdbcType=JdbcType.INTEGER), + @Result(column="order_no", property="orderNo", jdbcType=JdbcType.VARCHAR), + @Result(column="pay_serial_no", property="paySerialNo", jdbcType=JdbcType.VARCHAR), @Result(column="pay_type", property="payType", jdbcType=JdbcType.INTEGER), + @Result(column="mem_card_id", property="memCardId", jdbcType=JdbcType.BIGINT), + @Result(column="mem_card_type", property="memCardType", jdbcType=JdbcType.INTEGER), + @Result(column="mem_card_no", property="memCardNo", jdbcType=JdbcType.VARCHAR), + @Result(column="total_price", property="totalPrice", jdbcType=JdbcType.DECIMAL), + @Result(column="total_deduction_price", property="totalDeductionPrice", jdbcType=JdbcType.DECIMAL), + @Result(column="deduction_coupon_price", property="deductionCouponPrice", jdbcType=JdbcType.DECIMAL), + @Result(column="deduction_product_price", property="deductionProductPrice", jdbcType=JdbcType.DECIMAL), @Result(column="pay_gold", property="payGold", jdbcType=JdbcType.INTEGER), + @Result(column="payable_price", property="payablePrice", jdbcType=JdbcType.DECIMAL), @Result(column="pay_price", property="payPrice", jdbcType=JdbcType.DECIMAL), @Result(column="pay_real_price", property="payRealPrice", jdbcType=JdbcType.DECIMAL), - @Result(column="pay_serial_no", property="paySerialNo", jdbcType=JdbcType.VARCHAR), - @Result(column="deduction_price", property="deductionPrice", jdbcType=JdbcType.DECIMAL), @Result(column="order_status", property="orderStatus", jdbcType=JdbcType.INTEGER), - @Result(column="total_price", property="totalPrice", jdbcType=JdbcType.DECIMAL), + @Result(column="remarks", property="remarks", jdbcType=JdbcType.VARCHAR), @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="surplus_refund_price", property="surplusRefundPrice", jdbcType=JdbcType.DECIMAL), + @Result(column="surplus_refund_integral", property="surplusRefundIntegral", jdbcType=JdbcType.INTEGER), @Result(column="pay_time", property="payTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="finish_time", property="finishTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="cancel_time", property="cancelTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="cancel_remarks", property="cancelRemarks", jdbcType=JdbcType.VARCHAR), - @Result(column="finish_time", property="finishTime", jdbcType=JdbcType.TIMESTAMP), - @Result(column="remarks", property="remarks", jdbcType=JdbcType.VARCHAR), @Result(column="refund_time", property="refundTime", jdbcType=JdbcType.TIMESTAMP), - @Result(column="refund_price", property="refundPrice", jdbcType=JdbcType.DECIMAL), - @Result(column="refund_content", property="refundContent", jdbcType=JdbcType.VARCHAR), - @Result(column="company_id", property="companyId", jdbcType=JdbcType.BIGINT), - @Result(column="refusal_refund_content", property="refusalRefundContent", jdbcType=JdbcType.VARCHAR), + @Result(column="account_merchant_num", property="accountMerchantNum", jdbcType=JdbcType.VARCHAR), + @Result(column="profit_sharing_status", property="profitSharingStatus", jdbcType=JdbcType.BIT), + @Result(column="profit_sharing_record_id", property="profitSharingRecordId", jdbcType=JdbcType.BIGINT), + @Result(column="whether_check", property="whetherCheck", jdbcType=JdbcType.BIT), + @Result(column="whether_rebate", property="whetherRebate", jdbcType=JdbcType.BIT), + @Result(column="exception_status", property="exceptionStatus", jdbcType=JdbcType.BIT), + @Result(column="exception_content", property="exceptionContent", jdbcType=JdbcType.VARCHAR), @Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR), @Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR), - @Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR) + @Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_4", property="ext4", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_5", property="ext5", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_6", property="ext6", jdbcType=JdbcType.VARCHAR) }) List integralRebateOrder(); diff --git a/hai-service/src/main/java/com/hai/entity/BsIntegralRebate.java b/hai-service/src/main/java/com/hai/entity/BsIntegralRebate.java index cb814b01..38bd7dcb 100644 --- a/hai-service/src/main/java/com/hai/entity/BsIntegralRebate.java +++ b/hai-service/src/main/java/com/hai/entity/BsIntegralRebate.java @@ -25,7 +25,17 @@ public class BsIntegralRebate implements Serializable { private Long companyId; /** - * 1:卡券 2:在线加油 3:话费 4:第三方 + * + * 产品类型 + * 1:星巴克 + * 2:肯德基 + * 3:会员充值 + * 4:积分充值 + * 5:购买卡券 + * 6:加油服务 + * 7:优惠券包 + * 8:汇联通充值 + * 9:话费充值 */ private Integer type; @@ -319,4 +329,4 @@ public class BsIntegralRebate implements Serializable { sb.append("]"); return sb.toString(); } -} \ No newline at end of file +} diff --git a/hai-service/src/main/java/com/hai/enum_type/OrderLogoEnum.java b/hai-service/src/main/java/com/hai/enum_type/OrderLogoEnum.java deleted file mode 100644 index 35f6e150..00000000 --- a/hai-service/src/main/java/com/hai/enum_type/OrderLogoEnum.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.hai.enum_type; - -import java.util.Objects; - -/** - * 产品图片 - * @author hurui - */ -public enum OrderLogoEnum { - name1("orderLogo/coupon.png", 1), - name3("orderLogo/refuel.png", 3), - name4("orderLogo/kfc.png", 4), - name9("orderLogo/starbucks.png", 9), - name10("orderLogo/member-recharge.png", 10), - name20("orderLogo/call-charges.png", 20), - ; - - - private String imgUrl; - - private Integer type; - public static String getNameByImgUrl(Integer type) { - for (OrderLogoEnum ele : values()) { - if(Objects.equals(type,ele.getType())) return ele.getImgUrl(); - } - return null; - } - - OrderLogoEnum(String imgUrl, Integer type) { - this.imgUrl = imgUrl; - this.type = type; - } - - public Integer getType() { - return type; - } - - public void setType(Integer type) { - this.type = type; - } - - public String getImgUrl() { - return imgUrl; - } - - public void setImgUrl(String imgUrl) { - this.imgUrl = imgUrl; - } -} diff --git a/hai-service/src/main/java/com/hai/enum_type/OrderproductTypeEnum.java b/hai-service/src/main/java/com/hai/enum_type/OrderproductTypeEnum.java new file mode 100644 index 00000000..2c09bbf4 --- /dev/null +++ b/hai-service/src/main/java/com/hai/enum_type/OrderproductTypeEnum.java @@ -0,0 +1,64 @@ +package com.hai.enum_type; + +import java.util.Objects; + +public enum OrderproductTypeEnum { + type1(1 , "星巴克" , "orderLogo/starbucks.png"), + type2(2 , "肯德基" , "orderLogo/kfc.png"), + type3(3 , "会员充值" , "orderLogo/member-top-up.png"), + type4(4 , "积分充值" , "orderLogo/integral-top-up.png"), + type5(5 , "购买卡券" , "orderLogo/coupon.png"), + type6(6 , "加油服务" , "orderLogo/refuel-online.png"), + type7(7 , "优惠券包" , "orderLogo/coupon-packs.png"), + type8(8 , "汇联通充值" , "orderLogo/hlt.png"), + type9(9 , "话费充值" , "orderLogo/calls.png"), + ; + + private Integer type; + private String name; + private String logoImg; + + public static String getTypeByImgUrl(Integer type) { + for (OrderproductTypeEnum ele : values()) { + if(Objects.equals(type,ele.getType())) return ele.getLogoImg(); + } + return null; + } + + public static String getTypeByName(Integer type) { + for (OrderproductTypeEnum ele : values()) { + if(Objects.equals(type,ele.getType())) return ele.getName(); + } + return null; + } + + OrderproductTypeEnum(int type , String name , String logoImg) { + this.type = type; + this.name = name; + this.logoImg = logoImg; + } + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getLogoImg() { + return logoImg; + } + + public void setLogoImg(String logoImg) { + this.logoImg = logoImg; + } +} diff --git a/hai-service/src/main/java/com/hai/service/BsIntegralRebateService.java b/hai-service/src/main/java/com/hai/service/BsIntegralRebateService.java index d59c62f0..b5099cfe 100644 --- a/hai-service/src/main/java/com/hai/service/BsIntegralRebateService.java +++ b/hai-service/src/main/java/com/hai/service/BsIntegralRebateService.java @@ -77,24 +77,5 @@ public interface BsIntegralRebateService { **/ void deleteIntegralRebate(Long id); - /** - * @Author Sum1Dream - * @Name integralRebate - * @Description // 订单积分返利 - * @Date 11:32 2022/9/1 - * @Param [object] - * @Return void - */ - void integralRebate(JSONObject object); - - /** - * @Author Sum1Dream - * @Name integralRechargeRebate - * @Description // 话费订单返利 - * @Date 11:33 2022/9/1 - * @Param [object] - * @Return void - */ - void integralRechargeRebate(JSONObject object); } diff --git a/hai-service/src/main/java/com/hai/service/BsOrderRebateService.java b/hai-service/src/main/java/com/hai/service/BsOrderRebateService.java new file mode 100644 index 00000000..306e3156 --- /dev/null +++ b/hai-service/src/main/java/com/hai/service/BsOrderRebateService.java @@ -0,0 +1,68 @@ +package com.hai.service; + +import com.hai.entity.BsOperationLog; +import com.hai.entity.BsOrderRebate; +import com.hai.entity.HighOrder; + +import java.util.List; +import java.util.Map; + +/** + * @serviceName BsOrderRebateService.java + * @author Sum1Dream + * @version 1.0.0 + * @Description // 下单返利接口 + * @createTime 10:41 2023/1/31 + **/ +public interface BsOrderRebateService { + + /** + * @Author Sum1Dream + * @Name getOrderRebateByList + * @Description // 查询列表 + * @Date 10:42 2023/1/31 + * @Param [map] + * @Return java.util.List + */ + List getOrderRebateByList(Map map); + + /** + * @Author Sum1Dream + * @Name insertOrderRebate + * @Description // 新增 + * @Date 10:42 2023/1/31 + * @Param [bsOrderRebate] + * @Return void + */ + void insertOrderRebate(BsOrderRebate bsOrderRebate); + + /** + * @Author Sum1Dream + * @Name updateOrderRebate + * @Description // 修改 + * @Date 10:42 2023/1/31 + * @Param [bsOrderRebate] + * @Return void + */ + void updateOrderRebate(BsOrderRebate bsOrderRebate); + + /** + * @Author Sum1Dream + * @Name findOrderRebate + * @Description // 根据id 查询详情 + * @Date 10:43 2023/1/31 + * @Param [id] + * @Return com.hai.entity.BsOrderRebate + */ + BsOrderRebate findOrderRebate(Long id); + + /** + * @Author Sum1Dream + * @Name insertOrderRebate + * @Description // 插入积分返利记录 + * @Date 13:57 2023/1/31 + * @Param [orderId] + * @Return void + */ + void insertOrderRebate(HighOrder highOrder); +} diff --git a/hai-service/src/main/java/com/hai/service/impl/BsDistributionUserRelServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/BsDistributionUserRelServiceImpl.java index ebfecf36..04cebf46 100644 --- a/hai-service/src/main/java/com/hai/service/impl/BsDistributionUserRelServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/BsDistributionUserRelServiceImpl.java @@ -181,7 +181,7 @@ public class BsDistributionUserRelServiceImpl implements BsDistributionUserRelSe distributionUserRel.setAgentName(distributionUserRel.getAgentName()); distributionUserRel.setUserName(user.getName()); distributionRebate.setPopularizeUserId(distributionUserRel.getPopularizeUserId()); - distributionRebate.setTitle(object.getString("title")); + distributionRebate.setTitle(object.getString("name")); distributionRebate.setIntegralNum(object.getBigDecimal("integralNumFirst")); distributionRebate.setOrderNo(object.getString("orderNo")); distributionRebate.setExt1(object.getString("logoImg")); diff --git a/hai-service/src/main/java/com/hai/service/impl/BsIntegralRebateServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/BsIntegralRebateServiceImpl.java index 6f64041d..2e036f52 100644 --- a/hai-service/src/main/java/com/hai/service/impl/BsIntegralRebateServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/BsIntegralRebateServiceImpl.java @@ -97,93 +97,5 @@ public class BsIntegralRebateServiceImpl implements BsIntegralRebateService { bsIntegralRebateMapper.deleteByPrimaryKey(id); } - @Override - public void integralRebate(JSONObject object) { - - Map map = new HashMap<>(); - map.put("type" , object.getInteger("type")); - map.put("productId" , object.getLong("productId")); - map.put("companyId" , object.getLong("companyId")); - - if (object.getLong("companyId") != null) { - - BsIntegralRebate bsIntegralRebate = findIntegralRebateByMap(map); - - if (DateUtil.isEffectiveDate(object.getDate("createTime"), bsIntegralRebate.getStartTime() , bsIntegralRebate.getEndTime())) { - - HighOrder order = highOrderService.getOrderById(object.getLong("orderId")); - - order.setWhetherRebate(true); - - BigDecimal integralNum = object.getBigDecimal("price").multiply(bsIntegralRebate.getPercentage()).setScale( 0, BigDecimal.ROUND_HALF_UP ); - BigDecimal integralNumFirst = object.getBigDecimal("price").multiply(bsIntegralRebate.getFirstDistribution()).setScale( 0, BigDecimal.ROUND_HALF_UP ); - BigDecimal integralNumSecond = object.getBigDecimal("price").multiply(bsIntegralRebate.getSecondDistribution()).setScale( 0, BigDecimal.ROUND_HALF_UP ); - - order.setWhetherRebate(true); - - JSONObject jsonObject = new JSONObject(); - - jsonObject.put("integralNumFirst" , integralNumFirst); - jsonObject.put("integralNumSecond" , integralNumSecond); - jsonObject.put("title" , object.getString("name")); - jsonObject.put("orderNo" , order.getOrderNo()); - jsonObject.put("userId" , object.getLong("userId")); - jsonObject.put("logoImg" , object.getString("logoImg")); - - bsDistributionUserRelService.distributionRebate(jsonObject); - highOrderService.updateOrder(order); - highUserService.goldHandle(object.getLong("userId"), integralNum.intValue(), 1, 4, object.getLong("orderId") , object.getString("remark") + integralNum); - - - } - - - } - } - - @Override - public void integralRechargeRebate(JSONObject object) { - - Map map = new HashMap<>(); - map.put("type" , object.getInteger("type")); - map.put("productId" , object.getLong("productId")); - map.put("companyId" , object.getLong("companyId")); - - if (object.getLong("companyId") != null) { - - BsIntegralRebate bsIntegralRebate = findIntegralRebateByMap(map); - - if (DateUtil.isEffectiveDate(object.getDate("createTime"), bsIntegralRebate.getStartTime() , bsIntegralRebate.getEndTime())) { - JSONObject jsonObject = new JSONObject(); - OutRechargeOrder order = outRechargeOrderService.findByOrderId(object.getLong("orderId")); - - order.setWhetherRebate(true); - - BigDecimal integralNum = object.getBigDecimal("price").multiply(bsIntegralRebate.getPercentage()).setScale( 0, BigDecimal.ROUND_HALF_UP ); - if (bsIntegralRebate.getFirstDistribution() !=null) { - BigDecimal integralNumFirst = object.getBigDecimal("price").multiply(bsIntegralRebate.getFirstDistribution()).setScale( 0, BigDecimal.ROUND_HALF_UP ); - jsonObject.put("integralNumFirst" , integralNumFirst); - } - if (bsIntegralRebate.getSecondDistribution() !=null) { - BigDecimal integralNumSecond = object.getBigDecimal("price").multiply(bsIntegralRebate.getSecondDistribution()).setScale( 0, BigDecimal.ROUND_HALF_UP ); - jsonObject.put("integralNumSecond" , integralNumSecond); - } - - order.setWhetherRebate(true); - - jsonObject.put("title" , object.getString("name")); - jsonObject.put("orderNo" , order.getOrderNo()); - jsonObject.put("userId" , object.getLong("userId")); - jsonObject.put("logoImg" , object.getString("logoImg")); - - bsDistributionUserRelService.distributionRebate(jsonObject); - outRechargeOrderService.updateOrder(order); - highUserService.goldHandle(object.getLong("userId"), integralNum.intValue(), 1, 4, object.getLong("orderId") , object.getString("remark") + integralNum); - - } - - } - - } } diff --git a/hai-service/src/main/java/com/hai/service/impl/BsOrderRebateServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/BsOrderRebateServiceImpl.java new file mode 100644 index 00000000..a885b9e4 --- /dev/null +++ b/hai-service/src/main/java/com/hai/service/impl/BsOrderRebateServiceImpl.java @@ -0,0 +1,118 @@ +package com.hai.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.hai.common.utils.DateUtil; +import com.hai.dao.BsOrderRebateMapper; +import com.hai.entity.BsIntegralRebate; +import com.hai.entity.BsOrderRebate; +import com.hai.entity.BsOrderRebateExample; +import com.hai.entity.HighOrder; +import com.hai.enum_type.OrderproductTypeEnum; +import com.hai.service.*; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service("bsOrderRebateService") +public class BsOrderRebateServiceImpl implements BsOrderRebateService { + + @Resource + private BsOrderRebateMapper bsOrderRebateMapper; + + @Resource + private HighOrderService highOrderService; + + @Resource + private BsIntegralRebateService bsIntegralRebateService; + + @Resource + private BsDistributionUserRelService bsDistributionUserRelService; + + @Resource + private HighUserService highUserService; + + @Override + public List getOrderRebateByList(Map map) { + + BsOrderRebateExample example = new BsOrderRebateExample(); + + return null; + } + + @Override + public void insertOrderRebate(BsOrderRebate bsOrderRebate) { + bsOrderRebateMapper.insert(bsOrderRebate); + } + + @Override + public void updateOrderRebate(BsOrderRebate bsOrderRebate) { + bsOrderRebateMapper.updateByPrimaryKey(bsOrderRebate); + } + + @Override + public BsOrderRebate findOrderRebate(Long id) { + return bsOrderRebateMapper.selectByPrimaryKey(id); + } + + @Override + public void insertOrderRebate(HighOrder highOrder) { + + // 计算返利积分数量 + // 查询是否配置返利 + Map map = new HashMap<>(); + map.put("type" , highOrder.getProductType()); + map.put("companyId" , highOrder.getCompanyId()); + + BsIntegralRebate bsIntegralRebate = bsIntegralRebateService.findIntegralRebateByMap(map); + + // 判断是否配置返利内容 + if (bsIntegralRebate != null) { + + // 判断是否在返利条件 + if (DateUtil.isEffectiveDate(highOrder.getCreateTime(), bsIntegralRebate.getStartTime() , bsIntegralRebate.getEndTime())) { + + // 积分返利积分 + BigDecimal integralNum = highOrder.getPayRealPrice().multiply(bsIntegralRebate.getPercentage()).setScale( 0, BigDecimal.ROUND_HALF_UP ); + // 1级分销 + BigDecimal integralNumFirst = highOrder.getPayRealPrice().multiply(bsIntegralRebate.getFirstDistribution()).setScale( 0, BigDecimal.ROUND_HALF_UP ); + // 2级分销 + BigDecimal integralNumSecond = highOrder.getPayRealPrice().multiply(bsIntegralRebate.getSecondDistribution()).setScale( 0, BigDecimal.ROUND_HALF_UP ); + + // 定义请求对象 + JSONObject object = new JSONObject(); + // 拼接分销返利对象 + object.put("userId" , highOrder.getMemId()); + object.put("orderNo" , highOrder.getOrderNo()); + object.put("integralNumFirst" , integralNumFirst); + object.put("integralNumSecond" , integralNumSecond); + object.put("companyId", highOrder.getCompanyId()); + object.put("remark" , OrderproductTypeEnum.getTypeByName(highOrder.getProductType()) + "订单:"+ highOrder.getTitle() + "-" + highOrder.getOrderNo() + "积分返利:"); + object.put("name" , "下单" + OrderproductTypeEnum.getTypeByName(highOrder.getProductType()) + ":" + highOrder.getTitle()); + object.put("logoImg" , OrderproductTypeEnum.getTypeByImgUrl(highOrder.getProductType())); + + bsDistributionUserRelService.distributionRebate(object); + highUserService.goldHandle(highOrder.getMemId(), integralNum.intValue(), 1, 4, highOrder.getId(), object.getString("remark") + integralNum); + + // 查询积分返利记录 + BsOrderRebate orderRebate = new BsOrderRebate(); + orderRebate.setOrderId(highOrder.getId()); + orderRebate.setOrderNo(highOrder.getOrderNo()); + orderRebate.setCreateTime(new Date()); + orderRebate.setUpdateTime(new Date()); + orderRebate.setStatus(1); + orderRebate.setIntegralNum(integralNum.intValue()); + orderRebate.setUserId(highOrder.getMemId()); + orderRebate.setUserName(highOrder.getMemName()); + bsOrderRebateMapper.insert(orderRebate); + } + + } + + + } +} diff --git a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java index 4b0d2df3..778ad95b 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java @@ -2183,8 +2183,9 @@ public class HighOrderServiceImpl implements HighOrderService { return highOrderMapper.integralRebateOrder(); } + // todo 废弃代码 @Override - public JSONObject orderSource(Integer goodsType, Long goodsId , String orderNo , Long companyId , Integer productId) { + public JSONObject orderSource(Integer goodsType, Long goodsId , String orderNo , Long companyId , Integer productId) { JSONObject object = new JSONObject(); @@ -2236,7 +2237,7 @@ public class HighOrderServiceImpl implements HighOrderService { object.put("name" , "购买话费充值产品"); } - object.put("logoImg" , OrderLogoEnum.getNameByImgUrl(goodsType)); +// object.put("logoImg" , OrderLogoEnum.getNameByImgUrl(goodsType)); return object; }