|
@@ -3,6 +3,7 @@ package com.caimei365.order.service.impl;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.caimei365.order.components.HeliPayUtil;
|
|
|
+import com.caimei365.order.components.ProductService;
|
|
|
import com.caimei365.order.components.WeChatService;
|
|
|
import com.caimei365.order.constant.Constant;
|
|
|
import com.caimei365.order.mapper.BaseMapper;
|
|
@@ -60,6 +61,8 @@ public class HeliPayNonOrderServiceImpl implements HeliPayNonOrderService {
|
|
|
private RemoteCallService remoteCallService;
|
|
|
@Resource
|
|
|
private OrderClubMapper orderClubMapper;
|
|
|
+ @Resource
|
|
|
+ private ProductService productService;
|
|
|
|
|
|
@Override
|
|
|
public ResponseJson<PayCouponDto> getCouponRecord(PayCouponDto payCouponDto, HttpHeaders headers) {
|
|
@@ -1912,6 +1915,40 @@ public class HeliPayNonOrderServiceImpl implements HeliPayNonOrderService {
|
|
|
return ResponseJson.error("支付失败", null);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public ResponseJson<JSONObject> payCouponByBeans(HeliDto heliDto, HttpHeaders headers) {
|
|
|
+ Integer beans = baseMapper.findBeans(heliDto.getUserId());
|
|
|
+ CouponVo co = baseMapper.findCoupon(heliDto.getCouponId());
|
|
|
+ if (null == co) {
|
|
|
+ return ResponseJson.error("暂不可兑换该优惠券!", null);
|
|
|
+ }
|
|
|
+ double moneyCouponPrice = co.getMoneyCouponPrice();
|
|
|
+ int needBeans = (int) moneyCouponPrice;
|
|
|
+ if (beans < 1) {
|
|
|
+ return ResponseJson.error("采美豆数量不足!", null);
|
|
|
+ }
|
|
|
+ //给券
|
|
|
+ CouponClubPo couponClubPo = new CouponClubPo();
|
|
|
+ couponClubPo.setSource(heliDto.getSource());
|
|
|
+ couponClubPo.setUserId(heliDto.getUserId());
|
|
|
+ couponClubPo.setCouponId(heliDto.getCouponId());
|
|
|
+ couponClubPo.setStatus("1");
|
|
|
+ couponClubPo.setDelFlag("0");
|
|
|
+ couponClubPo.setCreateDate(new Date());
|
|
|
+ orderClubMapper.insertCouponClub(couponClubPo);
|
|
|
+ //记录采美豆消费
|
|
|
+ UserBeansHistoryPo userBeansHistory = new UserBeansHistoryPo();
|
|
|
+ userBeansHistory.setUserId(heliDto.getUserId());
|
|
|
+ userBeansHistory.setBeansType(17);
|
|
|
+ userBeansHistory.setType(2);
|
|
|
+ userBeansHistory.setAddTime(new Date());
|
|
|
+ userBeansHistory.setNum(needBeans);
|
|
|
+ userBeansHistory.setPushStatus(0);
|
|
|
+ userBeansHistory.setDelFlag(0);
|
|
|
+ productService.updateUserBeans(userBeansHistory, beans - needBeans, null);
|
|
|
+ return ResponseJson.success("抵扣成功!", null);
|
|
|
+ }
|
|
|
+
|
|
|
public void saveRoleRelation(Integer userId, String roleIds) {
|
|
|
if (StringUtils.isNotEmpty(roleIds)) {
|
|
|
// 设置用户角色
|