Browse Source

[POS][修改]:券支付核销后给成长值积分移到同步时

release_toaliyun_real
Stormeye Wu 6 years ago
parent
commit
6abc407b51
2 changed files with 33 additions and 111 deletions
  1. +6
    -73
      mallinkPosApi/src/main/java/com/iformall/controller/PosController.java
  2. +27
    -38
      mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java

+ 6
- 73
mallinkPosApi/src/main/java/com/iformall/controller/PosController.java View File

@@ -167,15 +167,15 @@ public class PosController extends BaseController {
"\"mem_phone_number\":\"string(选填)\"," +
"\"business_type\":\"string(0:核销1支付(必填)\"," +
"\"order_number_of_platform\":\"string(必填)\"," +
"\"order_amount\":\"string单位(分)(填)\"," +
"\"order_amount_left\":\"string单位(分)(填)\"," +
"\"order_amount\":\"string单位(分)(填)\"," +
"\"order_amount_left\":\"string单位(分)(填)\"," +
"\"order_create_sn\":\"string单位(分)(必填)\"," +
"\"payment_info\":{" +
"\"coupon_id\":\"string(必填)\"," +
"\"order_amount\":\"string单位(分)(填)\"," +
"\"amount_left\":\"string单位(分)(填)\"," +
"\"promotion_amount\":\"string单位(分)(填)\"," +
"\"amount_left_after_pay\":\"string单位(分)(填)\"" +
"\"order_amount\":\"string单位(分)(填)\"," +
"\"amount_left\":\"string单位(分)(填)\"," +
"\"promotion_amount\":\"string单位(分)(填)\"," +
"\"amount_left_after_pay\":\"string单位(分)(填)\"" +
"}}")
@PostMapping("/couponOrderVerifyCancel")
@SystemControllerLog(description = "券核销取消")
@@ -201,73 +201,6 @@ public class PosController extends BaseController {
return buildReturnMap(retObj, resKey, WxPayConstant.RET_SUCCESS, "",500, e.getMessage());
}
}
/*
@ApiOperation(value = "POS支付-券", notes = "{" +
"\"dev_id\":\"string(必填)\"," +
"\"nonce_str\":\"string(必填)\"," +
"\"tenant_id\":\"string(必填)\"," +
"\"merchant_id\":\"string(必填)\"," +
"\"bu_user_id\":\"string(必填)\"," +
"\"sel_co_list\":\"json array[券包ID list](必填),例[\"1\",\"2\",\"3\"]\"" +
"\"pos_order_id\":\"string(必填)\"," +
"\"pos_amount\":\"string(必填)\"}")
@PostMapping("/couponOrderPay")
@SystemControllerLog(description = "POS支付-券")
public Map<String, String> couponOrderPay(@RequestBody Map<String, String> params) {
JSONObject payContent = new JSONObject();

// 1. check sign
Map<String, String> retMap = checkSign(params, payContent);
if (retMap != null) {
// 签名相关异常返回
return retMap;
}
String resKey = payContent.getString(WxPayConstant.RES_KEY);
logger.info(WxPayConstant.RES_KEY + ": " + resKey);

try {
//retMap = posService.couponOrderVerifyDo(params, EnumPosActionType.PAY_VERIFY_PRE);
//return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "",null);
} catch (MallinkException e) {
return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", e.getErrorCode(), e.getMessage());
} catch (Exception e) {
return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "",500, e.getMessage());
}
return null;
}

@ApiOperation(value = "POS支付取消-券", notes = "{" +
"\"dev_id\":\"string(必填)\"," +
"\"tenant_id\":\"string(必填)\"," +
"\"merchant_id\":\"string(必填)\"," +
"\"bu_user_id\":\"string(必填)\"," +
"\"coupon_order_id\":\"string(必填)\" +" +
"\"nonce_str\":\"string(必填)\" +" +
"\"pos_order_id\":\"string(必填)\" }")
@PostMapping("/couponOrderPayCancel")
@SystemControllerLog(description = "POS支付取消-券")
public Map<String, String> couponOrderPayCancel(@RequestBody Map<String, String> params) {
JSONObject payContent = new JSONObject();

// 1. check sign
Map<String, String> retMap = checkSign(params, payContent);
if (retMap != null) {
// 签名相关异常返回
return retMap;
}
String resKey = payContent.getString(WxPayConstant.RES_KEY);
logger.info(WxPayConstant.RES_KEY + ": " + resKey);

try {
retMap = posService.couponOrderVerifyCancel(params, EnumPosActionType.PAY_VERIFY_PRE_CANCEL);
return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "",null);
} catch (MallinkException e) {
return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", e.getErrorCode(), e.getMessage());
} catch (Exception e) {
return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "",500, e.getMessage());
}
}
*/

@ApiOperation(value = "POS订单同步", notes = "支付成功/支付取消后订单同步")
@PostMapping("/posOrderSync")


+ 27
- 38
mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java View File

@@ -21,7 +21,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
import springfox.documentation.spring.web.json.Json;

import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -894,19 +893,9 @@ public class PosServiceImpl implements PosService {
logger.error(errMessage);
throw new MallinkException(ErrorCode.POS_COUPON_PAY_ERROR.getCode(), errMessage);
}
for (int i = 0; i < avaCoList.size(); i++) {
WxCouponOrderCVo couponOrderCVo = avaCoList.get(i);
boolean selCoupon = isSelCoupon(selCoArr, couponOrderCVo.getId());
try {
JSONObject couponObj = oneCouponPay(promotionCalc, couponOrderCVo, merchantId, buUserId, posOrderId, selCoupon);
couponList.add(couponObj);
} catch (MallinkException e) {
throw new MallinkException(e.getErrorCode(), e.getMessage());
} catch (Exception e) {
throw new MallinkException(500, e.getMessage());
}
}
} else if (config.getCoupon().equals(EnumPosCouponEnableType.MultiEnable.getCode())) {
}
if (config.getCoupon().equals(EnumPosCouponEnableType.SingleEnable.getCode()) ||
config.getCoupon().equals(EnumPosCouponEnableType.MultiEnable.getCode())) {
for (int i = 0; i < avaCoList.size(); i++) {
WxCouponOrderCVo couponOrderCVo = avaCoList.get(i);
boolean selCoupon = isSelCoupon(selCoArr, couponOrderCVo.getId());
@@ -1520,13 +1509,7 @@ public class PosServiceImpl implements PosService {
posCouponOrderVerify = posCouponOrderVerifyList.get(0);
if(posCouponOrderVerify != null) {
try {
PosCouponOrderVerify updateCouponOrderVerify = new PosCouponOrderVerify();
updateCouponOrderVerify.setId(posCouponOrderVerify.getId());
updateCouponOrderVerify.setTenantId(posCouponOrderVerify.getTenantId());
updateCouponOrderVerify.setState(EnumEnableType.Disable.getCode());
updateCouponOrderVerify.setUpdateDate(new Date());
posCouponOrderVerifyService.saveOrUpdate(updateCouponOrderVerify);
// posCouponOrderVerifyService.deleteById(posCouponOrderVerify.getId());
posCouponOrderVerifyService.deleteById(posCouponOrderVerify.getId());
} catch (Exception e) {
logger.error("db failed: couponOrder-" + couponOrderCVo.getId() + ", e:" + e.getMessage());
throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage());
@@ -1606,23 +1589,6 @@ public class PosServiceImpl implements PosService {
logger.error("核销异常:update num " + num);
throw new MallinkException(ErrorCode.VERIFY_ERROR.getCode(), "updatete num " + num);
}

// 3. 成长值
try {
WxOrder order = orderMapper.selectByPrimaryKey(couponOrderCVo.getOrderId());
int point = scoreRulesService.addScore2(EnumScoreType.CONSUMPTION, order, couponOrderCVo.getBusinessId());
retMap.put(WxPayConstant.POINT, point);
} catch (Exception e) {
logger.error("核销成长值异常:" + e.getMessage());
}

// 4. 积分
int credit = posAddCredit(couponOrderCVo, coupon, merchantId, buUserId);
if (credit > 0) {
retMap.put(WxPayConstant.CREDIT, credit);
} else {
retMap.put(WxPayConstant.CREDIT, 0);
}
logger.info("核销已完成: " + couponOrderCVo.getId());
}

@@ -2335,6 +2301,29 @@ public class PosServiceImpl implements PosService {
updateCO.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USED.getCode());
couponOrderMapper.updateByPrimaryKeySelective(updateCO);
}
WxCouponOrderCVo couponOrderCVo = couponOrderService.detailCUserVo(posPayOrderNo);
if (couponOrderCVo != null) {
// 3. 成长值
try {
WxOrder scoreOrder = orderMapper.selectByPrimaryKey(couponOrderCVo.getOrderId());
int point = scoreRulesService.addScore2(EnumScoreType.CONSUMPTION, scoreOrder, couponOrderCVo.getBusinessId());
} catch (Exception e) {
logger.error("交易核销成长值异常:" + e.getMessage());
}

WxCoupon wxCoupon = couponMapper.selectByPrimaryKey(couponOrderCVo.getCouponId());
if (wxCoupon == null) {
logger.error("券: coupon-" + wxCoupon.getId() + "不存在" + "couponOrder-" + couponOrderCVo.getId());
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL);
}

// 4. 积分
try {
int credit = posAddCredit(couponOrderCVo, wxCoupon, merchantBUser.getMerchantId(), merchantBUser.getId());
} catch (Exception e) {
logger.error("交易核销积分异常:" + e.getMessage());
}
}
// 3. 核销后处理
couponOrderService.sendInsideCouponVerifyMsg(merchantBUser.getTenantId(), couponOrderId, merchantBUser.getId());
return payOrder;


Loading…
Cancel
Save