|
|
@ -7,12 +7,15 @@ import com.hai.common.exception.ErrorHelp; |
|
|
|
import com.hai.common.exception.SysCode; |
|
|
|
import com.hai.common.exception.SysCode; |
|
|
|
import com.hai.common.pay.util.XmlUtil; |
|
|
|
import com.hai.common.pay.util.XmlUtil; |
|
|
|
import com.hai.common.pay.util.sdk.WXPayConstants; |
|
|
|
import com.hai.common.pay.util.sdk.WXPayConstants; |
|
|
|
|
|
|
|
import com.hai.common.security.AESEncodeUtil; |
|
|
|
import com.hai.common.utils.*; |
|
|
|
import com.hai.common.utils.*; |
|
|
|
import com.hai.config.*; |
|
|
|
import com.hai.config.*; |
|
|
|
import com.hai.dao.HighGasOrderPushMapper; |
|
|
|
import com.hai.dao.HighGasOrderPushMapper; |
|
|
|
import com.hai.dao.OutRechargeOrderMapper; |
|
|
|
import com.hai.dao.OutRechargeOrderMapper; |
|
|
|
import com.hai.dao.OutRechargeOrderMapperExt; |
|
|
|
import com.hai.dao.OutRechargeOrderMapperExt; |
|
|
|
import com.hai.entity.*; |
|
|
|
import com.hai.entity.*; |
|
|
|
|
|
|
|
import com.hai.enum_type.DiscountUseScope; |
|
|
|
|
|
|
|
import com.hai.enum_type.OperatorEnum; |
|
|
|
import com.hai.enum_type.OrderPushType; |
|
|
|
import com.hai.enum_type.OrderPushType; |
|
|
|
import com.hai.enum_type.RechargePayType; |
|
|
|
import com.hai.enum_type.RechargePayType; |
|
|
|
import com.hai.model.*; |
|
|
|
import com.hai.model.*; |
|
|
@ -28,12 +31,14 @@ import org.apache.http.entity.StringEntity; |
|
|
|
import org.apache.http.impl.client.CloseableHttpClient; |
|
|
|
import org.apache.http.impl.client.CloseableHttpClient; |
|
|
|
import org.apache.http.util.EntityUtils; |
|
|
|
import org.apache.http.util.EntityUtils; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import org.springframework.transaction.annotation.Isolation; |
|
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.web.bind.annotation.RequestParam; |
|
|
|
import org.springframework.web.bind.annotation.RequestParam; |
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.BigDecimal; |
|
|
|
|
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.*; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
|
|
@ -76,6 +81,17 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private BsRequestRecordService bsRequestRecordService; |
|
|
|
private BsRequestRecordService bsRequestRecordService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private BsConfigService bsConfigService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private SecConfigService secConfigService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private HighUserPayPasswordService highUserPayPasswordService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public List<OutRechargeOrder> getListRechargeOrder(Map<String, String> map) { |
|
|
|
public List<OutRechargeOrder> getListRechargeOrder(Map<String, String> map) { |
|
|
|
OutRechargeOrderExample example = new OutRechargeOrderExample(); |
|
|
|
OutRechargeOrderExample example = new OutRechargeOrderExample(); |
|
|
@ -105,6 +121,13 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
criteria.andUserPhoneEqualTo(MapUtils.getString(map, "phone")); |
|
|
|
criteria.andUserPhoneEqualTo(MapUtils.getString(map, "phone")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (MapUtils.getInteger(map, "status") != null) { |
|
|
|
|
|
|
|
criteria.andPayStatusEqualTo(MapUtils.getInteger(map, "status")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (MapUtils.getInteger(map, "rechargeStatus") != null) { |
|
|
|
|
|
|
|
criteria.andRechargeStatusEqualTo(MapUtils.getInteger(map, "rechargeStatus")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(map.get("payTimeS")) && StringUtils.isNotBlank(map.get("payTimeE"))) { |
|
|
|
if (StringUtils.isNotBlank(map.get("payTimeS")) && StringUtils.isNotBlank(map.get("payTimeE"))) { |
|
|
|
criteria.andPayTimeBetween( |
|
|
|
criteria.andPayTimeBetween( |
|
|
@ -134,8 +157,167 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
@Transactional(propagation= Propagation.REQUIRES_NEW) |
|
|
|
@Transactional( |
|
|
|
public void insertOrder(OutRechargeOrder outRechargeOrder) throws Exception { |
|
|
|
isolation = Isolation.SERIALIZABLE, |
|
|
|
|
|
|
|
propagation= Propagation.REQUIRES_NEW) |
|
|
|
|
|
|
|
public OutRechargeOrder insertOrder(JSONObject object) throws Exception { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OutRechargeOrder outRechargeOrder = new OutRechargeOrder(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HighUser user = highUserService.findByUserId(object.getLong("userId")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 产品id
|
|
|
|
|
|
|
|
Long goodsId = object.getLong("goodsId"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 充值内容
|
|
|
|
|
|
|
|
String rechargeContent = object.getString("rechargeContent"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 查询产品详情
|
|
|
|
|
|
|
|
OutRechargePriceModel outRechargePrice = outRechargePriceService.findById(goodsId , null); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> listMap = new HashMap<>(); |
|
|
|
|
|
|
|
listMap.put("productType", "3"); |
|
|
|
|
|
|
|
listMap.put("returnType", 1); |
|
|
|
|
|
|
|
listMap.put("sourceId", goodsId); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 查询产品积分抵扣比例
|
|
|
|
|
|
|
|
BsProductDiscount bsProductDiscount = bsConfigService.getProductDiscountByMap(listMap); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 判断充值系统是否关闭
|
|
|
|
|
|
|
|
if (!secConfigService.isConfig("RECHARGE" , "1")) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.RECHARGE_CLOSE, ""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HighDiscountUserRel highDiscountUserRel = null; |
|
|
|
|
|
|
|
// 判断是否有优惠券
|
|
|
|
|
|
|
|
if (object.getLong("memDiscountId") != null) { |
|
|
|
|
|
|
|
outRechargeOrder.setMemDiscountId(object.getLong("memDiscountId")); |
|
|
|
|
|
|
|
// 卡优惠券信息
|
|
|
|
|
|
|
|
highDiscountUserRel = highDiscountUserRelService.getRelById(object.getLong("memDiscountId")); |
|
|
|
|
|
|
|
if (highDiscountUserRel == null || highDiscountUserRel.getStatus() != 1) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券状态错误"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!highDiscountUserRel.getHighDiscount().getUseScope().equals(DiscountUseScope.type1.getType()) |
|
|
|
|
|
|
|
&& !highDiscountUserRel.getHighDiscount().getUseScope().equals(DiscountUseScope.type3.getType())) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法使用此优惠券"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
outRechargeOrder.setPayRealPrice(outRechargePrice.getPayPrice()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 优惠券抵扣
|
|
|
|
|
|
|
|
if (highDiscountUserRel != null) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
outRechargeOrder.setMemDiscountName(highDiscountUserRel.getHighDiscount().getDiscountName()); |
|
|
|
|
|
|
|
BigDecimal payPrice = new BigDecimal(0); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 卡卷类型 1:满减 2:抵扣 3:折扣
|
|
|
|
|
|
|
|
if (highDiscountUserRel.getHighDiscount().getDiscountType() == 1) { |
|
|
|
|
|
|
|
// 如果商品支付总额 小于 满减价格
|
|
|
|
|
|
|
|
if (outRechargePrice.getRechargePrice().compareTo(highDiscountUserRel.getHighDiscount().getDiscountCondition()) > 0) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.UN_MEMBER_ERROR, "订单未达到"+highDiscountUserRel.getHighDiscount().getDiscountCondition()+"元,无法使用此优惠券"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 计算支付金额 = 商品充值总额 - 满减额度
|
|
|
|
|
|
|
|
payPrice = outRechargePrice.getRechargePrice().subtract(highDiscountUserRel.getHighDiscount().getDiscountPrice()); |
|
|
|
|
|
|
|
outRechargeOrder.setDiscountDeductionPrice(highDiscountUserRel.getHighDiscount().getDiscountPrice()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 卡卷类型 1:满减 2:抵扣 3:折扣
|
|
|
|
|
|
|
|
if (highDiscountUserRel.getHighDiscount().getDiscountType() == 2) { |
|
|
|
|
|
|
|
// 计算支付金额 = 商品充值总额 - 满减额度
|
|
|
|
|
|
|
|
payPrice = outRechargePrice.getRechargePrice().subtract(highDiscountUserRel.getHighDiscount().getDiscountPrice()); |
|
|
|
|
|
|
|
outRechargeOrder.setDiscountDeductionPrice(highDiscountUserRel.getHighDiscount().getDiscountPrice()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 卡卷类型 1:满减 2:抵扣 3:折扣
|
|
|
|
|
|
|
|
if (highDiscountUserRel.getHighDiscount().getDiscountType() == 3) { |
|
|
|
|
|
|
|
BigDecimal discountPrice = highDiscountUserRel.getHighDiscount().getDiscountPrice(); |
|
|
|
|
|
|
|
// 订单总额 * 折扣
|
|
|
|
|
|
|
|
payPrice = outRechargePrice.getRechargePrice().multiply(discountPrice); |
|
|
|
|
|
|
|
outRechargeOrder.setDiscountDeductionPrice(outRechargePrice.getRechargePrice().subtract(payPrice)); |
|
|
|
|
|
|
|
outRechargeOrder.setPayRealPrice(payPrice); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 如果总额小于0
|
|
|
|
|
|
|
|
if (payPrice.compareTo(new BigDecimal("0")) < 0) { |
|
|
|
|
|
|
|
outRechargeOrder.setPayRealPrice(new BigDecimal("0")); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
outRechargeOrder.setPayRealPrice(payPrice); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 判断积分数量是否大于0
|
|
|
|
|
|
|
|
if (object.getLong("integralNum") > 0 && bsProductDiscount.getDiscount().compareTo(new BigDecimal("0")) > 0) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 判断用户积分是否够
|
|
|
|
|
|
|
|
if (object.getLong("integralNum") > user.getGold()) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "用户积分不足"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 积分抵扣金额
|
|
|
|
|
|
|
|
BigDecimal integralDeductionPrice = object.getBigDecimal("integralNum").divide(new BigDecimal(100).setScale(2, RoundingMode.HALF_DOWN)); |
|
|
|
|
|
|
|
// 最高可抵扣金额
|
|
|
|
|
|
|
|
BigDecimal maxIntegralDeductionPrice = outRechargeOrder.getPayRealPrice().multiply(bsProductDiscount.getDiscount()).divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_DOWN); |
|
|
|
|
|
|
|
// 判读积分是否大于限制额度
|
|
|
|
|
|
|
|
if (maxIntegralDeductionPrice.compareTo(integralDeductionPrice) < 0) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单最大抵扣积分金额:" + maxIntegralDeductionPrice); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 判断积分抵扣比例是否为100% 并且积分数量是否可以抵扣最后的支付金额
|
|
|
|
|
|
|
|
if (bsProductDiscount.getDiscount().compareTo(new BigDecimal(100)) == 0 && integralDeductionPrice.compareTo(outRechargeOrder.getPayRealPrice()) == 0) { |
|
|
|
|
|
|
|
// 查询用户支付密码
|
|
|
|
|
|
|
|
HighUserPayPassword userPayPassword = highUserPayPasswordService.getDetailByUser(object.getLong("userId")); |
|
|
|
|
|
|
|
if (userPayPassword == null) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_SET_USER_PAY_PWD, ""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isBlank(object.getString("password"))) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_ENTER_USER_PAY_PWD, ""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 校验支付密码
|
|
|
|
|
|
|
|
if (!AESEncodeUtil.aesEncrypt(object.getString("password")).equals(userPayPassword.getPassword())) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.USER_PAY_PWD_ERROR, ""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
outRechargeOrder.setIntegralDeductionPrice(integralDeductionPrice); |
|
|
|
|
|
|
|
outRechargeOrder.setPayRealPrice(outRechargeOrder.getPayRealPrice().subtract(outRechargeOrder.getIntegralDeductionPrice())); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
outRechargeOrder.setUserId(object.getLong("userId")); |
|
|
|
|
|
|
|
outRechargeOrder.setIntegralNum(object.getBigDecimal("integralNum")); |
|
|
|
|
|
|
|
outRechargeOrder.setRechargeContent(rechargeContent); |
|
|
|
|
|
|
|
outRechargeOrder.setCompanyId(outRechargePrice.getCompanyId()); |
|
|
|
|
|
|
|
outRechargeOrder.setUserName(object.getString("username")); |
|
|
|
|
|
|
|
outRechargeOrder.setRechargeType(outRechargePrice.getRechargeType()); |
|
|
|
|
|
|
|
outRechargeOrder.setUserPhone(object.getString("phone")); |
|
|
|
|
|
|
|
outRechargeOrder.setOrderNo("RCG" + DateUtil.date2String(new Date(),"yyyyMMddHHmmss") + IDGenerator.nextId(5)); |
|
|
|
|
|
|
|
outRechargeOrder.setCreateTimed(new Date()); |
|
|
|
|
|
|
|
outRechargeOrder.setGoodsId(goodsId); |
|
|
|
|
|
|
|
outRechargeOrder.setType(1); |
|
|
|
|
|
|
|
outRechargeOrder.setOrderPrice(outRechargePrice.getRechargePrice()); |
|
|
|
|
|
|
|
outRechargeOrder.setOperatorName(OperatorEnum.getNameByType(outRechargePrice.getOperatorType())); |
|
|
|
|
|
|
|
outRechargeOrder.setOperatorType(outRechargePrice.getOperatorType()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 判断积分支付是否扣完金额
|
|
|
|
|
|
|
|
if (outRechargeOrder.getPayRealPrice().compareTo(new BigDecimal(0)) == 0) { |
|
|
|
|
|
|
|
// 201:充值中 202:充值成功 203:充值失败 204:未充值
|
|
|
|
|
|
|
|
outRechargeOrder.setRechargeStatus(204); |
|
|
|
|
|
|
|
// 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款
|
|
|
|
|
|
|
|
outRechargeOrder.setPayStatus(102); |
|
|
|
|
|
|
|
outRechargeOrder.setPayTime(new Date()); |
|
|
|
|
|
|
|
outRechargeOrder.setPaySerialNo("22" + DateUtil.date2String(new Date(),"yyyyMMddHHmmss") + IDGenerator.nextId(5)); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// 201:充值中 202:充值成功 203:充值失败 204:未充值
|
|
|
|
|
|
|
|
outRechargeOrder.setRechargeStatus(204); |
|
|
|
|
|
|
|
// 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款
|
|
|
|
|
|
|
|
outRechargeOrder.setPayStatus(101); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 使用优惠券
|
|
|
|
// 使用优惠券
|
|
|
|
if (outRechargeOrder.getMemDiscountId() != null) { |
|
|
|
if (outRechargeOrder.getMemDiscountId() != null) { |
|
|
|
HighDiscountUserRel discountUserRel = highDiscountUserRelService.getRelById(outRechargeOrder.getMemDiscountId()); |
|
|
|
HighDiscountUserRel discountUserRel = highDiscountUserRelService.getRelById(outRechargeOrder.getMemDiscountId()); |
|
|
@ -147,16 +329,22 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
code.setStatus(3); |
|
|
|
code.setStatus(3); |
|
|
|
highDiscountAgentCodeService.updateCode(code); |
|
|
|
highDiscountAgentCodeService.updateCode(code); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (outRechargeOrder.getIntegralNum() != null) { |
|
|
|
|
|
|
|
highUserService.goldHandle(outRechargeOrder.getUserId(), outRechargeOrder.getIntegralNum().intValue(), 2, 2, outRechargeOrder.getId()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
outRechargeOrderMapper.insert(outRechargeOrder); |
|
|
|
outRechargeOrderMapper.insert(outRechargeOrder); |
|
|
|
|
|
|
|
|
|
|
|
if (outRechargeOrder.getRechargeStatus() == 201 && outRechargeOrder.getPayStatus() == 102) { |
|
|
|
if (outRechargeOrder.getPayStatus() == 102) { |
|
|
|
pollRequest(outRechargeOrder); |
|
|
|
pollRequest(outRechargeOrder); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return outRechargeOrder; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
@Transactional(propagation= Propagation.REQUIRES_NEW) |
|
|
|
|
|
|
|
public void updateOrder(OutRechargeOrder outRechargeOrder) { |
|
|
|
public void updateOrder(OutRechargeOrder outRechargeOrder) { |
|
|
|
outRechargeOrderMapper.updateByPrimaryKey(outRechargeOrder); |
|
|
|
outRechargeOrderMapper.updateByPrimaryKey(outRechargeOrder); |
|
|
|
} |
|
|
|
} |
|
|
@ -366,13 +554,14 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
} |
|
|
|
} |
|
|
|
order.setPaySerialNo(consumptionResult.getString("orderId")); // 支付流水号
|
|
|
|
order.setPaySerialNo(consumptionResult.getString("orderId")); // 支付流水号
|
|
|
|
order.setPayRealPrice(order.getPayRealPrice()); // 实付金额
|
|
|
|
order.setPayRealPrice(order.getPayRealPrice()); // 实付金额
|
|
|
|
outRechargeOrderService.pollRequest(order); |
|
|
|
|
|
|
|
order.setPayStatus(102); |
|
|
|
order.setPayStatus(102); |
|
|
|
order.setRechargeStatus(201); |
|
|
|
order.setRechargeStatus(204); |
|
|
|
order.setLaborUnionCard(userCard.getCardNo()); |
|
|
|
order.setLaborUnionCard(userCard.getCardNo()); |
|
|
|
order.setPayType(3); |
|
|
|
order.setPayType(3); |
|
|
|
order.setPayTime(new Date()); // 支付时间
|
|
|
|
order.setPayTime(new Date()); // 支付时间
|
|
|
|
updateOrder(order); |
|
|
|
updateOrder(order); |
|
|
|
|
|
|
|
outRechargeOrderService.pollRequest(order); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -387,7 +576,6 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
@Transactional(propagation= Propagation.REQUIRES_NEW) |
|
|
|
|
|
|
|
public void rechargeOrderToRefund(Long orderId) throws Exception { |
|
|
|
public void rechargeOrderToRefund(Long orderId) throws Exception { |
|
|
|
OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId); |
|
|
|
OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId); |
|
|
|
|
|
|
|
|
|
|
@ -396,8 +584,26 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单不处于已支付状态"); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单不处于已支付状态"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 充值状态:201:充值中 202:充值成功 203:充值失败 204:未充值
|
|
|
|
|
|
|
|
if (order.getRechargeStatus() == 201) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单处于充值中状态"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 1:支付宝 2:微信 3:汇联通工会卡 4:银联 5:银联分期
|
|
|
|
|
|
|
|
if (order.getPayType() == null) { |
|
|
|
|
|
|
|
// 退还积分
|
|
|
|
|
|
|
|
if (order.getIntegralNum() != null) { |
|
|
|
|
|
|
|
highUserService.goldHandle(order.getUserId(), order.getIntegralNum().intValue(), 1, 3, order.getId()); |
|
|
|
|
|
|
|
if (order.getPayRealPrice().compareTo(new BigDecimal(0)) == 0) { |
|
|
|
|
|
|
|
order.setPayStatus(105); |
|
|
|
|
|
|
|
order.setRechargeStatus(203); |
|
|
|
|
|
|
|
order.setRefundTime(new Date()); |
|
|
|
|
|
|
|
outRechargeOrderService.updateOrder(order); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
// 微信退款
|
|
|
|
// 微信退款
|
|
|
|
if (order.getPayType() == 1) { |
|
|
|
if (order.getPayType() == 2) { |
|
|
|
Map<String,String> param = new HashMap<>(); |
|
|
|
Map<String,String> param = new HashMap<>(); |
|
|
|
param.put("appid", "wx637bd6f7314daa46"); |
|
|
|
param.put("appid", "wx637bd6f7314daa46"); |
|
|
|
param.put("mch_id", "1289663601"); |
|
|
|
param.put("mch_id", "1289663601"); |
|
|
@ -428,7 +634,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 工会卡退款
|
|
|
|
// 工会卡退款
|
|
|
|
if (order.getPayType() == 2) { |
|
|
|
if (order.getPayType() == 3) { |
|
|
|
JSONObject jsonObject = HuiLianTongUnionCardConfig.refund( "HFR"+new Date().getTime() , order.getOrderNo()); |
|
|
|
JSONObject jsonObject = HuiLianTongUnionCardConfig.refund( "HFR"+new Date().getTime() , order.getOrderNo()); |
|
|
|
|
|
|
|
|
|
|
|
if (jsonObject == null) { |
|
|
|
if (jsonObject == null) { |
|
|
@ -451,8 +657,6 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 银联退款
|
|
|
|
// 银联退款
|
|
|
|
if (order.getPayType() == 4) { |
|
|
|
if (order.getPayType() == 4) { |
|
|
|
// 订单退款
|
|
|
|
// 订单退款
|
|
|
@ -467,6 +671,8 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
order.setRefundFee(order.getPayRealPrice()); |
|
|
|
order.setRefundFee(order.getPayRealPrice()); |
|
|
|
outRechargeOrderService.updateOrder(order); |
|
|
|
outRechargeOrderService.updateOrder(order); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (order.getMemDiscountId() != null) { |
|
|
|
if (order.getMemDiscountId() != null) { |
|
|
|
HighDiscountUserRel rel = highDiscountUserRelService.getRelById(order.getMemDiscountId()); |
|
|
|
HighDiscountUserRel rel = highDiscountUserRelService.getRelById(order.getMemDiscountId()); |
|
|
@ -514,7 +720,6 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) |
|
|
|
|
|
|
|
public void pollRequest(OutRechargeOrder outRechargeOrder) throws Exception { |
|
|
|
public void pollRequest(OutRechargeOrder outRechargeOrder) throws Exception { |
|
|
|
|
|
|
|
|
|
|
|
// 查询充值产品
|
|
|
|
// 查询充值产品
|
|
|
@ -552,14 +757,20 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
|
|
|
|
|
|
|
|
for (String s : rechargePlatform) { |
|
|
|
for (String s : rechargePlatform) { |
|
|
|
// 尖椒充值
|
|
|
|
// 尖椒充值
|
|
|
|
if (s.equals("1") && type == 2) { |
|
|
|
if (s.equals("1") && (type == 2 || type == 0)) { |
|
|
|
object.put("out_order_id" ,orderNo ); |
|
|
|
object.put("out_order_id" ,orderNo ); |
|
|
|
object.put("amount" , outRechargePrice.getRechargePrice()); |
|
|
|
object.put("amount" , outRechargePrice.getRechargePrice()); |
|
|
|
object.put("mobile" , outRechargeOrder.getRechargeContent()); |
|
|
|
object.put("mobile" , outRechargeOrder.getRechargeContent()); |
|
|
|
if (outRechargePrice.getRechargeType() == 1) { |
|
|
|
if (outRechargePrice.getRechargeType() == 1) { |
|
|
|
object.put("is_fast" , 1); |
|
|
|
object.put("is_fast" , 1); |
|
|
|
} |
|
|
|
} |
|
|
|
RechargeConfig.rechargeOrderByJj(object); |
|
|
|
JSONObject returnObject = RechargeConfig.rechargeOrderByJj(object); |
|
|
|
|
|
|
|
object.put("return_content" , returnObject); |
|
|
|
|
|
|
|
if (returnObject != null && returnObject.getLong("code") == 200) { |
|
|
|
|
|
|
|
childOrder.setStatus(102); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
childOrder.setStatus(103); |
|
|
|
|
|
|
|
} |
|
|
|
rechargePlatformType = 1; |
|
|
|
rechargePlatformType = 1; |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
@ -567,7 +778,13 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
object.put("out_trade_num" , orderNo); |
|
|
|
object.put("out_trade_num" , orderNo); |
|
|
|
object.put("product_id" , outRechargePrice.getGoodsId()); |
|
|
|
object.put("product_id" , outRechargePrice.getGoodsId()); |
|
|
|
object.put("mobile" , outRechargeOrder.getRechargeContent()); |
|
|
|
object.put("mobile" , outRechargeOrder.getRechargeContent()); |
|
|
|
RechargeConfig.rechargeOrderByLy(object); |
|
|
|
JSONObject returnObject = RechargeConfig.rechargeOrderByLy(object); |
|
|
|
|
|
|
|
object.put("return_content" , returnObject); |
|
|
|
|
|
|
|
if (returnObject != null && returnObject.getLong("errno") == 0) { |
|
|
|
|
|
|
|
childOrder.setStatus(102); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
childOrder.setStatus(103); |
|
|
|
|
|
|
|
} |
|
|
|
rechargePlatformType = 2; |
|
|
|
rechargePlatformType = 2; |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
@ -576,7 +793,6 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
childOrder.setOrderNo(orderNo); |
|
|
|
childOrder.setOrderNo(orderNo); |
|
|
|
childOrder.setCreateTime(new Date()); |
|
|
|
childOrder.setCreateTime(new Date()); |
|
|
|
childOrder.setParentOrderId(outRechargeOrder.getId()); |
|
|
|
childOrder.setParentOrderId(outRechargeOrder.getId()); |
|
|
|
childOrder.setStatus(102); |
|
|
|
|
|
|
|
childOrder.setRechargePlatform(rechargePlatformType); |
|
|
|
childOrder.setRechargePlatform(rechargePlatformType); |
|
|
|
childOrder.setUpdateTime(new Date()); |
|
|
|
childOrder.setUpdateTime(new Date()); |
|
|
|
outRechargeChildOrderService.insertOrder(childOrder); |
|
|
|
outRechargeChildOrderService.insertOrder(childOrder); |
|
|
@ -586,7 +802,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
requestRecord.setCreateTime(new Date()); |
|
|
|
requestRecord.setCreateTime(new Date()); |
|
|
|
requestRecord.setUpdateTime(new Date()); |
|
|
|
requestRecord.setUpdateTime(new Date()); |
|
|
|
requestRecord.setOrderNo(orderNo); |
|
|
|
requestRecord.setOrderNo(orderNo); |
|
|
|
requestRecord.setRequestContent(String.valueOf(object)); |
|
|
|
requestRecord.setRequestContent(object.toJSONString()); |
|
|
|
requestRecord.setOperatorId(0L); |
|
|
|
requestRecord.setOperatorId(0L); |
|
|
|
requestRecord.setOperatorName("系统生成"); |
|
|
|
requestRecord.setOperatorName("系统生成"); |
|
|
|
requestRecord.setSourceId(childOrder.getId().toString()); |
|
|
|
requestRecord.setSourceId(childOrder.getId().toString()); |
|
|
@ -594,6 +810,21 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
|
|
|
|
|
|
|
|
bsRequestRecordService.insertRequestRecord(requestRecord); |
|
|
|
bsRequestRecordService.insertRequestRecord(requestRecord); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 判断是否充值提交成功
|
|
|
|
|
|
|
|
if (childOrder.getStatus() == 102) { |
|
|
|
|
|
|
|
outRechargeOrder.setRechargeStatus(201); |
|
|
|
|
|
|
|
outRechargeOrderService.updateOrder(outRechargeOrder); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public Integer rechargeOrderNum(Long userId) { |
|
|
|
|
|
|
|
OutRechargeOrderExample example = new OutRechargeOrderExample(); |
|
|
|
|
|
|
|
OutRechargeOrderExample.Criteria criteria = example.createCriteria(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
criteria.andUserIdEqualTo(userId); |
|
|
|
|
|
|
|
criteria.andPayStatusEqualTo(101); |
|
|
|
|
|
|
|
return outRechargeOrderMapper.selectByExample(example).size(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|