|
|
@ -7,6 +7,7 @@ import com.hai.common.exception.SysCode; |
|
|
|
import com.hai.common.utils.ResponseMsgUtil; |
|
|
|
import com.hai.common.utils.ResponseMsgUtil; |
|
|
|
import com.hai.entity.ApiMerchants; |
|
|
|
import com.hai.entity.ApiMerchants; |
|
|
|
import com.hai.entity.HighGoldRec; |
|
|
|
import com.hai.entity.HighGoldRec; |
|
|
|
|
|
|
|
import com.hai.entity.HighUser; |
|
|
|
import com.hai.model.ResponseData; |
|
|
|
import com.hai.model.ResponseData; |
|
|
|
import com.hai.service.*; |
|
|
|
import com.hai.service.*; |
|
|
|
import com.hai.service.impl.OutRechargeOrderServiceImpl; |
|
|
|
import com.hai.service.impl.OutRechargeOrderServiceImpl; |
|
|
@ -112,9 +113,90 @@ public class OrderRebateController { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/recycleIntegralPre", method = RequestMethod.POST) |
|
|
|
|
|
|
|
@ResponseBody |
|
|
|
|
|
|
|
@ApiOperation(value = "退款回收积分预处理") |
|
|
|
|
|
|
|
public ResponseData recycleIntegralPre(@RequestBody JSONObject object , HttpServletRequest request ) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String ip = ""; |
|
|
|
|
|
|
|
// 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for
|
|
|
|
|
|
|
|
if (request.getHeader("x-forwarded-for") == null) { |
|
|
|
|
|
|
|
ip = request.getRemoteAddr(); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
ip = request.getHeader("x-forwarded-for"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) { |
|
|
|
|
|
|
|
log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(object.getString("apiKey")) || |
|
|
|
|
|
|
|
StringUtils.isBlank(object.getString("merchId")) || |
|
|
|
|
|
|
|
StringUtils.isBlank(object.getString("orderNo")) || |
|
|
|
|
|
|
|
StringUtils.isBlank(object.getString("userId")) || |
|
|
|
|
|
|
|
StringUtils.isBlank(object.getString("sign")) |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
log.error("getRechargeProduct error!", "请求参数校验失败!"); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (apiMerchants == null) { |
|
|
|
|
|
|
|
log.error("getRechargeProduct error!", "商户号错误!"); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_NOT_EXIST); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String , Object> map = new HashMap<>(); |
|
|
|
|
|
|
|
map.put("apiKey" , object.getString("apiKey")); |
|
|
|
|
|
|
|
map.put("merchId" , object.getString("merchId")); |
|
|
|
|
|
|
|
map.put("orderNo" , object.getString("orderNo")); |
|
|
|
|
|
|
|
map.put("userId" , object.getString("userId")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!secConfigService.isSignVerify(map , object.getString("sign"))) { |
|
|
|
|
|
|
|
log.error("getRechargeProduct error!", "签名校验失败!"); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> mapGold = new HashMap<>(); |
|
|
|
|
|
|
|
mapGold.put("goldType", 1); |
|
|
|
|
|
|
|
mapGold.put("resType", object.getInteger("productType")); |
|
|
|
|
|
|
|
mapGold.put("resId", object.getLong("orderId")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<HighGoldRec> goldRecs = highGoldRecService.getGoldRec(mapGold); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Integer integralNum = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 查询用户信息
|
|
|
|
|
|
|
|
HighUser user = highUserService.findByUserId(object.getLong("userId")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (HighGoldRec goldRec : goldRecs) { |
|
|
|
|
|
|
|
integralNum += goldRec.getGold(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (integralNum > user.getGold()) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "积分数量不足"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String remark = "订单" + object.getString("orderNo") + "退款,退还积分:" + integralNum; |
|
|
|
|
|
|
|
// 积分退款
|
|
|
|
|
|
|
|
highUserService.goldHandle(user.getId(), integralNum,2, object.getInteger("productType"), object.getLong("orderId") , remark); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success("操作成功"); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
log.error("HighOrderController --> getBackendToken() error!", e); |
|
|
|
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/recycleIntegral", method = RequestMethod.POST) |
|
|
|
@RequestMapping(value = "/recycleIntegral", method = RequestMethod.POST) |
|
|
|
@ResponseBody |
|
|
|
@ResponseBody |
|
|
|
@ApiOperation(value = "退款回收积分") |
|
|
|
@ApiOperation(value = "退款回收积分处理") |
|
|
|
public ResponseData recycleIntegral(@RequestBody JSONObject object , HttpServletRequest request ) { |
|
|
|
public ResponseData recycleIntegral(@RequestBody JSONObject object , HttpServletRequest request ) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
@ -173,7 +255,7 @@ public class OrderRebateController { |
|
|
|
for (HighGoldRec goldRec : goldRecs) { |
|
|
|
for (HighGoldRec goldRec : goldRecs) { |
|
|
|
String remark = "订单" + object.getString("orderNo") + "退款,退还积分:" + goldRec.getGold(); |
|
|
|
String remark = "订单" + object.getString("orderNo") + "退款,退还积分:" + goldRec.getGold(); |
|
|
|
// 积分退款
|
|
|
|
// 积分退款
|
|
|
|
highUserService.goldHandle(goldRec.getUserId(), goldRec.getGold(),1, object.getInteger("productType"), object.getLong("orderId") , remark); |
|
|
|
highUserService.goldHandle(goldRec.getUserId(), goldRec.getGold(),2, object.getInteger("productType"), object.getLong("orderId") , remark); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success("操作成功"); |
|
|
|
return ResponseMsgUtil.success("操作成功"); |
|
|
|