商家是否会员支付控制
登录获取手机号报错问题 团购卷会员卡支付 个人中心 客服电话
This commit is contained in:
@@ -60,7 +60,7 @@ public class LoginContoller {
|
|||||||
RedisUtil redisUtil;
|
RedisUtil redisUtil;
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping("/wx/business/login")
|
// @RequestMapping("/wx/business/login")
|
||||||
public Result wxBusinessLogin(@RequestParam(value = "code", required = false) String code,
|
public Result wxBusinessLogin(@RequestParam(value = "code", required = false) String code,
|
||||||
@RequestParam(value = "rawData", required = false) String rawData,
|
@RequestParam(value = "rawData", required = false) String rawData,
|
||||||
@RequestParam(value = "signature", required = false) String signature
|
@RequestParam(value = "signature", required = false) String signature
|
||||||
@@ -178,10 +178,13 @@ public class LoginContoller {
|
|||||||
String openid = SessionKeyOpenId.getString("openid");
|
String openid = SessionKeyOpenId.getString("openid");
|
||||||
String sessionKey = SessionKeyOpenId.getString("session_key");
|
String sessionKey = SessionKeyOpenId.getString("session_key");
|
||||||
String data = WxMaCryptUtils.decrypt(sessionKey, encryptedData, ivStr);
|
String data = WxMaCryptUtils.decrypt(sessionKey, encryptedData, ivStr);
|
||||||
if (ObjectUtil.isNotEmpty(data) && JSONObject.parseObject(data).containsKey("phoneNumber")) {
|
try {
|
||||||
return Result.success(CodeEnum.SUCCESS, JSONObject.parseObject(data).get("phoneNumber"));
|
if (ObjectUtil.isNotEmpty(data) && JSONObject.parseObject(data).containsKey("phoneNumber")) {
|
||||||
|
return Result.success(CodeEnum.SUCCESS, JSONObject.parseObject(data).get("phoneNumber"));
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
return Result.fail("获取手机号失败");
|
||||||
}
|
}
|
||||||
return Result.fail("获取手机号失败");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public class PayController {
|
|||||||
// String orderType = map.get("orderType").toString();
|
// String orderType = map.get("orderType").toString();
|
||||||
String payType = map.get("payType");
|
String payType = map.get("payType");
|
||||||
String userId = "";
|
String userId = "";
|
||||||
if (environment.equals("wx")) {
|
if (environment.equals("wx") && payType.equals("wechatPay")) {
|
||||||
userId = TokenUtil.parseParamFromToken(token).getString("openId");
|
userId = TokenUtil.parseParamFromToken(token).getString("openId");
|
||||||
} else {
|
} else {
|
||||||
userId = TokenUtil.parseParamFromToken(token).getString("userId");
|
userId = TokenUtil.parseParamFromToken(token).getString("userId");
|
||||||
@@ -81,10 +81,7 @@ public class PayController {
|
|||||||
//订单支付 orderId:62,payType=wechatPay,userId:or1l860rwM-rU_j9KrgMOwued
|
//订单支付 orderId:62,payType=wechatPay,userId:or1l860rwM-rU_j9KrgMOwued
|
||||||
log.info("订单支付 orderId:{},payType={},userId:{}", orderId, payType, userId);
|
log.info("订单支付 orderId:{},payType={},userId:{}", orderId, payType, userId);
|
||||||
try {
|
try {
|
||||||
// if(StringUtils.isNotBlank(orderType) && orderType.equals("group")){
|
return payService.groupOrderPay(orderId, payType, userId, IpUtil.getIpAddr(request), map.get("pwd"));
|
||||||
// return payService.groupOrderPay(orderId, payType, userId, IpUtil.getIpAddr(request));
|
|
||||||
// }
|
|
||||||
return payService.groupOrderPay(orderId, payType, userId, IpUtil.getIpAddr(request));
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,8 +76,24 @@ public class UserContoller {
|
|||||||
// return jsonObject;
|
// return jsonObject;
|
||||||
// }
|
// }
|
||||||
@GetMapping("/shopUserInfo")
|
@GetMapping("/shopUserInfo")
|
||||||
public Result shopUserInfo(@RequestParam("userId") String userId ,@RequestParam("shopId") String shopId ) throws Exception {
|
public Result shopUserInfo(@RequestParam("userId") String userId ,@RequestHeader("openId") String openId,@RequestParam("shopId") String shopId ) throws Exception {
|
||||||
TbShopUser shopUser = shopUserMapper.selectByUserIdAndShopId(userId,shopId);
|
TbShopUser shopUser = shopUserMapper.selectByUserIdAndShopId(userId,shopId);
|
||||||
|
if (ObjectUtil.isEmpty(shopUser)) {
|
||||||
|
shopUser = new TbShopUser();
|
||||||
|
shopUser.setAmount(BigDecimal.ZERO);
|
||||||
|
shopUser.setIsVip(Byte.parseByte("0"));
|
||||||
|
shopUser.setCreditAmount(BigDecimal.ZERO);
|
||||||
|
shopUser.setConsumeAmount(BigDecimal.ZERO);
|
||||||
|
shopUser.setConsumeNumber(0);
|
||||||
|
shopUser.setLevelConsume(BigDecimal.ZERO);
|
||||||
|
shopUser.setStatus(Byte.parseByte("1"));
|
||||||
|
shopUser.setShopId(shopId);
|
||||||
|
shopUser.setUserId(userId);
|
||||||
|
shopUser.setMiniOpenId(openId);
|
||||||
|
shopUser.setCreatedAt(System.currentTimeMillis());
|
||||||
|
shopUser.setUpdatedAt(System.currentTimeMillis());
|
||||||
|
shopUserMapper.insert(shopUser);
|
||||||
|
}
|
||||||
return Result.success(CodeEnum.SUCCESS,shopUser);
|
return Result.success(CodeEnum.SUCCESS,shopUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ public class TbShopInfo implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private String shopQrcode;
|
private String shopQrcode;
|
||||||
private String isOpenYhq;
|
private String isOpenYhq;
|
||||||
|
private Byte isUseVip;
|
||||||
/**
|
/**
|
||||||
* 商户标签
|
* 商户标签
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -101,6 +101,8 @@ public class TbUserInfo implements Serializable {
|
|||||||
|
|
||||||
private String pwd;
|
private String pwd;
|
||||||
|
|
||||||
|
private String custPhone="400-6666-389";
|
||||||
|
|
||||||
|
|
||||||
public String getAvatar() {
|
public String getAvatar() {
|
||||||
return avatar;
|
return avatar;
|
||||||
@@ -110,6 +112,14 @@ public class TbUserInfo implements Serializable {
|
|||||||
this.avatar = avatar;
|
this.avatar = avatar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getCustPhone() {
|
||||||
|
return custPhone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCustPhone(String custPhone) {
|
||||||
|
this.custPhone = custPhone;
|
||||||
|
}
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public Integer getId() {
|
public Integer getId() {
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ public class GroupOrderDetailsVo {
|
|||||||
* 商家名称
|
* 商家名称
|
||||||
*/
|
*/
|
||||||
private String shopName;
|
private String shopName;
|
||||||
|
private Byte isUseVip;
|
||||||
/**
|
/**
|
||||||
* 商家电话
|
* 商家电话
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import java.math.BigDecimal;
|
|||||||
public class OrderConfirmVo {
|
public class OrderConfirmVo {
|
||||||
private String proId;
|
private String proId;
|
||||||
private String shopId;
|
private String shopId;
|
||||||
|
private Byte isUseVip;
|
||||||
/**
|
/**
|
||||||
* 商品图片
|
* 商品图片
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ public class GroupOrderInfoService {
|
|||||||
|
|
||||||
TbShopInfo shopInfo = shopInfoMapper.selectByPrimaryKey(groupOrder.getShopId());
|
TbShopInfo shopInfo = shopInfoMapper.selectByPrimaryKey(groupOrder.getShopId());
|
||||||
result.setShopName(shopInfo.getShopName());
|
result.setShopName(shopInfo.getShopName());
|
||||||
|
result.setIsUseVip(shopInfo.getIsUseVip());
|
||||||
String distance = LocationUtils.getDistanceString(
|
String distance = LocationUtils.getDistanceString(
|
||||||
Double.parseDouble(lng), Double.parseDouble(lat),
|
Double.parseDouble(lng), Double.parseDouble(lat),
|
||||||
Double.parseDouble(shopInfo.getLng()), Double.parseDouble(shopInfo.getLat()));
|
Double.parseDouble(shopInfo.getLng()), Double.parseDouble(shopInfo.getLat()));
|
||||||
|
|||||||
@@ -385,139 +385,135 @@ public class PayService {
|
|||||||
|
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Result groupOrderPay(String orderId, String payType, String userId, String ip) throws JsonProcessingException {
|
public Result groupOrderPay(String orderId, String payType, String userId, String ip,String pwd) throws JsonProcessingException {
|
||||||
TbGroupOrderInfo orderInfo = tbGroupOrderInfoMapper.queryById(Integer.valueOf(orderId));
|
TbGroupOrderInfo orderInfo = tbGroupOrderInfoMapper.queryById(Integer.valueOf(orderId));
|
||||||
|
|
||||||
if (!"unpaid".equals(orderInfo.getStatus())) {
|
if (!"unpaid".equals(orderInfo.getStatus())) {
|
||||||
return Result.fail("订单状态异常,不允许支付");
|
return Result.fail("订单状态异常,不允许支付");
|
||||||
}
|
}
|
||||||
|
if(payType.equals("deposit")){
|
||||||
TbMerchantAccount tbMerchantAccount = merchantAccountMapper.selectByShopId(orderInfo.getShopId().toString());
|
int count = tbShopPayTypeMapper.countSelectByShopIdAndPayType(orderInfo.getShopId().toString(), "deposit");
|
||||||
if (tbMerchantAccount == null) {
|
if (count < 1) {
|
||||||
throw new MsgException("生成订单错误");
|
return Result.fail("店铺未开通此支付方式");
|
||||||
}
|
|
||||||
|
|
||||||
if (ObjectUtil.isNull(tbMerchantAccount)) {
|
|
||||||
return Result.fail("没有对应的商户");
|
|
||||||
}
|
|
||||||
|
|
||||||
TbMerchantThirdApply thirdApply = tbMerchantThirdApplyMapper.selectByPrimaryKey(Integer.valueOf(tbMerchantAccount.getId()));
|
|
||||||
|
|
||||||
if (ObjectUtil.isEmpty(thirdApply) || ObjectUtil.isNull(thirdApply)) {
|
|
||||||
return Result.fail("支付通道不存在");
|
|
||||||
}
|
|
||||||
StringBuffer body=new StringBuffer();
|
|
||||||
body.append(orderInfo.getProName());
|
|
||||||
TbOrderPayment payment = tbOrderPaymentMapper.selectByOrderId(orderId);
|
|
||||||
if (ObjectUtil.isEmpty(payment) || payment == null) {
|
|
||||||
payment = new TbOrderPayment();
|
|
||||||
payment.setPayTypeId("ysk");
|
|
||||||
payment.setAmount(orderInfo.getOrderAmount());
|
|
||||||
payment.setPaidAmount(orderInfo.getPayAmount());
|
|
||||||
payment.setHasRefundAmount(BigDecimal.ZERO);
|
|
||||||
if (payType.equals("wechatPay")) {
|
|
||||||
payment.setPayName("微信支付");
|
|
||||||
payment.setPayType("wechatPay");
|
|
||||||
} else if (payType.equals("aliPay")) {
|
|
||||||
payment.setPayName("支付宝支付");
|
|
||||||
payment.setPayType("aliPay");
|
|
||||||
}
|
}
|
||||||
payment.setReceived(payment.getAmount());
|
|
||||||
payment.setChangeFee(BigDecimal.ZERO);
|
TbUserInfo userInfo= tbUserInfoMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getUserId()));
|
||||||
// payment.setMemberId(orderInfo.getMemberId());//会员Id
|
if(ObjectUtil.isEmpty(userInfo)){
|
||||||
payment.setShopId(orderInfo.getShopId().toString());
|
return Result.fail("未获取到用户信息");
|
||||||
payment.setOrderId(orderInfo.getId().toString());
|
|
||||||
payment.setCreatedAt(System.currentTimeMillis());
|
|
||||||
tbOrderPaymentMapper.insert(payment);
|
|
||||||
} else {
|
|
||||||
if (payType.equals("wechatPay")) {
|
|
||||||
payment.setPayName("微信支付");
|
|
||||||
payment.setPayType("wechatPay");
|
|
||||||
} else if (payType.equals("aliPay")) {
|
|
||||||
payment.setPayName("支付宝支付");
|
|
||||||
payment.setPayType("aliPay");
|
|
||||||
}
|
}
|
||||||
payment.setUpdatedAt(System.currentTimeMillis());
|
if(!userInfo.getPwd().equals(MD5Utils.md5(pwd))){
|
||||||
tbOrderPaymentMapper.updateByPrimaryKey(payment);
|
return Result.fail("支付密码错误");
|
||||||
|
}
|
||||||
|
|
||||||
|
TbShopUser user = tbShopUserMapper.selectByUserIdAndShopId(userId,orderInfo.getShopId().toString());
|
||||||
|
if (ObjectUtil.isEmpty(user) || !"1".equals(user.getIsVip().toString())) {
|
||||||
|
return Result.failCode("会员卡余额不足","1");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (N.gt(orderInfo.getPayAmount(), user.getAmount())) {
|
||||||
|
return Result.failCode("会员卡余额不足","2");
|
||||||
|
}
|
||||||
|
|
||||||
|
user.setAmount(user.getAmount().subtract(orderInfo.getOrderAmount()));
|
||||||
|
user.setConsumeAmount(user.getConsumeAmount().add(orderInfo.getPayAmount()));
|
||||||
|
user.setConsumeNumber(user.getConsumeNumber() + 1);
|
||||||
|
user.setUpdatedAt(System.currentTimeMillis());
|
||||||
|
tbShopUserMapper.updateByPrimaryKeySelective(user);
|
||||||
|
TbShopUserFlow flow = new TbShopUserFlow();
|
||||||
|
flow.setShopUserId(Integer.valueOf(user.getId()));
|
||||||
|
flow.setBizCode("accountGroupPay");
|
||||||
|
flow.setBizName("会员储值卡支付团购卷");
|
||||||
|
flow.setAmount(orderInfo.getOrderAmount());
|
||||||
|
flow.setBalance(user.getAmount());
|
||||||
|
flow.setCreateTime(new Date());
|
||||||
|
tbShopUserFlowMapper.insert(flow);
|
||||||
|
|
||||||
|
orderInfo.setPayAmount(orderInfo.getOrderAmount());
|
||||||
|
orderInfo.setPayType("deposit");
|
||||||
|
orderInfo.setStatus("unused");
|
||||||
|
orderInfo.setPayOrderNo("deposit".concat(SnowFlakeUtil.generateOrderNo()));
|
||||||
|
tbGroupOrderInfoMapper.update(orderInfo);
|
||||||
|
// JSONObject jsonObject = new JSONObject();
|
||||||
|
// jsonObject.put("token", "");
|
||||||
|
// jsonObject.put("type", "create");
|
||||||
|
// jsonObject.put("orderId", orderId);
|
||||||
|
//
|
||||||
|
// producer.putOrderCollect(jsonObject.toJSONString());
|
||||||
|
|
||||||
|
return Result.success(CodeEnum.SUCCESS);
|
||||||
}
|
}
|
||||||
if("ysk".equals(thirdPayType)){
|
else {
|
||||||
PayReq req = new PayReq();
|
TbMerchantAccount tbMerchantAccount = merchantAccountMapper.selectByShopId(orderInfo.getShopId().toString());
|
||||||
|
if (tbMerchantAccount == null) {
|
||||||
req.setAppId(thirdApply.getAppId());
|
throw new MsgException("生成订单错误");
|
||||||
req.setTimestamp(System.currentTimeMillis());
|
|
||||||
req.setIp(ip);
|
|
||||||
req.setMercOrderNo(orderInfo.getOrderNo());
|
|
||||||
req.setNotifyUrl(callBackGroupurl+"Ysk");
|
|
||||||
req.setPayAmt(payment.getAmount().setScale(2, BigDecimal.ROUND_DOWN).toPlainString());
|
|
||||||
if (payType.equals("wechatPay")) {
|
|
||||||
req.setPayType("03");
|
|
||||||
req.setPayWay("WXZF");//WXZF ZFBZF UNIONPAY
|
|
||||||
} else if (payType.equals("aliPay")) {
|
|
||||||
req.setPayWay("ZFBZF");
|
|
||||||
}
|
}
|
||||||
req.setSubject("零点八零:团购卷");
|
|
||||||
req.setUserId(userId);
|
|
||||||
|
|
||||||
|
if (ObjectUtil.isNull(tbMerchantAccount)) {
|
||||||
|
return Result.fail("没有对应的商户");
|
||||||
|
}
|
||||||
|
|
||||||
Map<String, Object> map = BeanUtil.transBeanMap(req);
|
TbMerchantThirdApply thirdApply = tbMerchantThirdApplyMapper.selectByPrimaryKey(Integer.valueOf(tbMerchantAccount.getId()));
|
||||||
req.setSign(MD5Util.encrypt(map, thirdApply.getAppToken(), true));
|
|
||||||
|
|
||||||
ResponseEntity<String> response = restTemplate.postForEntity(url.concat("trans/pay"), req, String.class);
|
if (ObjectUtil.isEmpty(thirdApply) || ObjectUtil.isNull(thirdApply)) {
|
||||||
|
return Result.fail("支付通道不存在");
|
||||||
|
}
|
||||||
if (response.getStatusCodeValue() == 200 && ObjectUtil.isNotEmpty(response.getBody())) {
|
StringBuffer body=new StringBuffer();
|
||||||
JSONObject object = JSONObject.parseObject(response.getBody());
|
body.append(orderInfo.getProName());
|
||||||
log.info("团购卷支付响应:{}",object);
|
TbOrderPayment payment = tbOrderPaymentMapper.selectByOrderId(orderInfo.getOrderNo());
|
||||||
if (object.get("code").equals("0")) {
|
if (ObjectUtil.isEmpty(payment) || payment == null) {
|
||||||
payment.setTradeNumber(object.getJSONObject("data").get("orderNumber").toString());
|
payment = new TbOrderPayment();
|
||||||
payment.setUpdatedAt(System.currentTimeMillis());
|
payment.setPayTypeId("ysk");
|
||||||
tbOrderPaymentMapper.updateByPrimaryKeySelective(payment);
|
payment.setAmount(orderInfo.getOrderAmount());
|
||||||
orderInfo.setPayType(payType);
|
payment.setPaidAmount(orderInfo.getPayAmount());
|
||||||
orderInfo.setPayOrderNo(payment.getTradeNumber());
|
payment.setHasRefundAmount(BigDecimal.ZERO);
|
||||||
tbGroupOrderInfoMapper.update(orderInfo);
|
if (payType.equals("wechatPay")) {
|
||||||
JSONObject jsonObject1 = new JSONObject();
|
payment.setPayName("微信支付");
|
||||||
jsonObject1.put("status", "success");
|
payment.setPayType("wechatPay");
|
||||||
jsonObject1.put("msg", "成功");
|
} else if (payType.equals("aliPay")) {
|
||||||
jsonObject1.put("type", "");
|
payment.setPayName("支付宝支付");
|
||||||
jsonObject1.put("data", new JSONArray());
|
payment.setPayType("aliPay");
|
||||||
jsonObject1.put("amount", 0);
|
|
||||||
tbProductMapper.upGroupRealSalesNumber(orderInfo.getProId().toString(), orderInfo.getNumber());
|
|
||||||
return Result.success(CodeEnum.SUCCESS, object.getJSONObject("data"));
|
|
||||||
} else {
|
|
||||||
return Result.fail("支付失败");
|
|
||||||
}
|
}
|
||||||
|
payment.setReceived(payment.getAmount());
|
||||||
|
payment.setChangeFee(BigDecimal.ZERO);
|
||||||
|
// payment.setMemberId(orderInfo.getMemberId());
|
||||||
|
payment.setShopId(orderInfo.getShopId().toString());
|
||||||
|
payment.setOrderId(orderInfo.getOrderNo());
|
||||||
|
payment.setCreatedAt(System.currentTimeMillis());
|
||||||
|
tbOrderPaymentMapper.insert(payment);
|
||||||
|
} else {
|
||||||
|
if (payType.equals("wechatPay")) {
|
||||||
|
payment.setPayName("微信支付");
|
||||||
|
payment.setPayType("wechatPay");
|
||||||
|
} else if (payType.equals("aliPay")) {
|
||||||
|
payment.setPayName("支付宝支付");
|
||||||
|
payment.setPayType("aliPay");
|
||||||
|
}
|
||||||
|
payment.setUpdatedAt(System.currentTimeMillis());
|
||||||
|
tbOrderPaymentMapper.updateByPrimaryKey(payment);
|
||||||
}
|
}
|
||||||
}else {
|
if("ysk".equals(thirdPayType)){
|
||||||
String reqbody="";
|
PayReq req = new PayReq();
|
||||||
|
req.setAppId(thirdApply.getAppId());
|
||||||
if(body.length()>15){
|
req.setTimestamp(System.currentTimeMillis());
|
||||||
reqbody=body.substring(0,6).concat("....").concat(body.substring(body.length()-6,body.length())).toString();
|
req.setIp(ip);
|
||||||
}else {
|
req.setMercOrderNo(orderInfo.getOrderNo());
|
||||||
reqbody=body.toString();
|
req.setNotifyUrl(callBackGroupurl+"Ysk");
|
||||||
}
|
req.setPayAmt(payment.getAmount().setScale(2, BigDecimal.ROUND_DOWN).toPlainString());
|
||||||
PublicResp<WxScanPayResp> publicResp= thirdPayService.scanpay(
|
if (payType.equals("wechatPay")) {
|
||||||
thirdUrl,
|
req.setPayType("03");
|
||||||
thirdApply.getAppId(),
|
req.setPayWay("WXZF");//WXZF ZFBZF UNIONPAY
|
||||||
reqbody,
|
} else if (payType.equals("aliPay")) {
|
||||||
reqbody,
|
req.setPayWay("ZFBZF");
|
||||||
payment.getAmount().setScale(2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)).longValue(),
|
}
|
||||||
"WECHAT",
|
req.setSubject("零点八零:团购卷");
|
||||||
thirdApply.getSmallAppid(),
|
req.setUserId(userId);
|
||||||
userId,
|
Map<String, Object> map = BeanUtil.transBeanMap(req);
|
||||||
ip,
|
req.setSign(MD5Util.encrypt(map, thirdApply.getAppToken(), true));
|
||||||
// orderInfo.getOrderNo(),
|
ResponseEntity<String> response = restTemplate.postForEntity(url.concat("trans/pay"), req, String.class);
|
||||||
DateUtils.getsdfTimesSS(),
|
if (response.getStatusCodeValue() == 200 && ObjectUtil.isNotEmpty(response.getBody())) {
|
||||||
thirdApply.getStoreId(),
|
JSONObject object = JSONObject.parseObject(response.getBody());
|
||||||
callBackGroupurl,
|
log.info("团购卷支付响应:{}",object);
|
||||||
null,
|
if (object.get("code").equals("0")) {
|
||||||
thirdApply.getAppToken());
|
payment.setTradeNumber(object.getJSONObject("data").get("orderNumber").toString());
|
||||||
if(ObjectUtil.isNotNull(publicResp)&&ObjectUtil.isNotEmpty(publicResp)){
|
|
||||||
if("000000".equals(publicResp.getCode())){
|
|
||||||
WxScanPayResp wxScanPayResp= publicResp.getObjData();
|
|
||||||
log.info("团购订单下单结果2:{}",wxScanPayResp);
|
|
||||||
// if("TRADE_SUCCESS".equals(wxScanPayResp.getState())||"TRADE_AWAIT".equals(wxScanPayResp.getState())){
|
|
||||||
if("TRADE_AWAIT".equals(wxScanPayResp.getState())){
|
|
||||||
payment.setTradeNumber(wxScanPayResp.getPayOrderId());
|
|
||||||
payment.setUpdatedAt(System.currentTimeMillis());
|
payment.setUpdatedAt(System.currentTimeMillis());
|
||||||
tbOrderPaymentMapper.updateByPrimaryKeySelective(payment);
|
tbOrderPaymentMapper.updateByPrimaryKeySelective(payment);
|
||||||
orderInfo.setPayType(payType);
|
orderInfo.setPayType(payType);
|
||||||
@@ -530,63 +526,70 @@ public class PayService {
|
|||||||
jsonObject1.put("data", new JSONArray());
|
jsonObject1.put("data", new JSONArray());
|
||||||
jsonObject1.put("amount", 0);
|
jsonObject1.put("amount", 0);
|
||||||
tbProductMapper.upGroupRealSalesNumber(orderInfo.getProId().toString(), orderInfo.getNumber());
|
tbProductMapper.upGroupRealSalesNumber(orderInfo.getProId().toString(), orderInfo.getNumber());
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
return Result.success(CodeEnum.SUCCESS, object.getJSONObject("data"));
|
||||||
return Result.success(CodeEnum.SUCCESS,mapper.readTree(wxScanPayResp.getPayInfo()));
|
} else {
|
||||||
} else{
|
return Result.fail("支付失败");
|
||||||
return Result.fail(wxScanPayResp.getNote());
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
log.info("支付金额为");
|
||||||
|
String reqbody="";
|
||||||
|
|
||||||
|
if(body.length()>15){
|
||||||
|
reqbody=body.substring(0,6).concat("....").concat(body.substring(body.length()-6,body.length())).toString();
|
||||||
}else {
|
}else {
|
||||||
return Result.fail(publicResp.getMsg());
|
reqbody=body.toString();
|
||||||
|
}
|
||||||
|
PublicResp<WxScanPayResp> publicResp= thirdPayService.scanpay(
|
||||||
|
thirdUrl,
|
||||||
|
thirdApply.getAppId(),
|
||||||
|
reqbody,
|
||||||
|
reqbody,
|
||||||
|
payment.getAmount().setScale(2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)).longValue(),
|
||||||
|
"WECHAT",
|
||||||
|
thirdApply.getSmallAppid(),
|
||||||
|
userId,
|
||||||
|
ip,
|
||||||
|
// orderInfo.getOrderNo(),
|
||||||
|
DateUtils.getsdfTimesSS(),
|
||||||
|
thirdApply.getStoreId(),
|
||||||
|
callBackGroupurl,
|
||||||
|
null,
|
||||||
|
thirdApply.getAppToken());
|
||||||
|
if(ObjectUtil.isNotNull(publicResp)&&ObjectUtil.isNotEmpty(publicResp)){
|
||||||
|
if("000000".equals(publicResp.getCode())){
|
||||||
|
WxScanPayResp wxScanPayResp= publicResp.getObjData();
|
||||||
|
log.info("团购订单下单结果2:{}",wxScanPayResp);
|
||||||
|
if("TRADE_AWAIT".equals(wxScanPayResp.getState())){
|
||||||
|
payment.setTradeNumber(wxScanPayResp.getPayOrderId());
|
||||||
|
payment.setUpdatedAt(System.currentTimeMillis());
|
||||||
|
tbOrderPaymentMapper.updateByPrimaryKeySelective(payment);
|
||||||
|
orderInfo.setPayType(payType);
|
||||||
|
orderInfo.setPayOrderNo(payment.getTradeNumber());
|
||||||
|
tbGroupOrderInfoMapper.update(orderInfo);
|
||||||
|
JSONObject jsonObject1 = new JSONObject();
|
||||||
|
jsonObject1.put("status", "success");
|
||||||
|
jsonObject1.put("msg", "成功");
|
||||||
|
jsonObject1.put("type", "");
|
||||||
|
jsonObject1.put("data", new JSONArray());
|
||||||
|
jsonObject1.put("amount", 0);
|
||||||
|
tbProductMapper.upGroupRealSalesNumber(orderInfo.getProId().toString(), orderInfo.getNumber());
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
return Result.success(CodeEnum.SUCCESS,mapper.readTree(wxScanPayResp.getPayInfo()));
|
||||||
|
} else{
|
||||||
|
return Result.fail(wxScanPayResp.getNote());
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
return Result.fail(publicResp.getMsg());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return Result.fail("失败");
|
||||||
}
|
}
|
||||||
return Result.fail("失败");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Result returngroupOrder(ReturnGroupOrderDto param) {
|
public Result returngroupOrder(ReturnGroupOrderDto param) {
|
||||||
TbGroupOrderInfo groupOrderInfo = tbGroupOrderInfoMapper.queryById(param.getOrderId());
|
|
||||||
List<TbGroupOrderCoupon> tbGroupOrderCoupons = orderCouponService.queryNoRefundByOrderId(param.getOrderId());
|
|
||||||
if (param.getNum() > tbGroupOrderCoupons.size()) {
|
|
||||||
return Result.fail("可退数量不足");
|
|
||||||
}
|
|
||||||
for (int i = 0; i < param.getNum(); i++) {
|
|
||||||
TbGroupOrderCoupon coupon = tbGroupOrderCoupons.get(i);
|
|
||||||
coupon.setIsRefund(1);
|
|
||||||
coupon.setRefundAmount(param.getRefundAmount());
|
|
||||||
coupon.setRefundDesc(param.getRefundDesc());
|
|
||||||
coupon.setRefundReason(param.getRefundReason());
|
|
||||||
orderCouponService.update(coupon);
|
|
||||||
}
|
|
||||||
TbMerchantThirdApply thirdApply = tbMerchantThirdApplyMapper.selectByPrimaryKey(groupOrderInfo.getMerchantId());
|
|
||||||
MsgException.checkNull(thirdApply, "支付参数配置错误");
|
|
||||||
|
|
||||||
ReturnOrderReq req = new ReturnOrderReq();
|
|
||||||
req.setAppId(thirdApply.getAppId());
|
|
||||||
req.setTimestamp(System.currentTimeMillis());
|
|
||||||
req.setOrderNumber(groupOrderInfo.getPayOrderNo());
|
|
||||||
req.setAmount(param.getRefundAmount().toString());
|
|
||||||
req.setMercRefundNo(groupOrderInfo.getOrderNo());
|
|
||||||
req.setRefundReason("团购卷:退货");
|
|
||||||
req.setPayPassword(thirdApply.getPayPassword());
|
|
||||||
Map<String, Object> map = BeanUtil.transBean2Map(req);
|
|
||||||
req.setSign(MD5Util.encrypt(map, thirdApply.getAppToken(), true));
|
|
||||||
log.info("groupOrderReturn req:{}", JSONUtil.toJsonStr(req));
|
|
||||||
ResponseEntity<String> response = restTemplate.postForEntity(url.concat("merchantOrder/returnOrder"), req, String.class);
|
|
||||||
log.info("groupOrderReturn:{}", response.getBody());
|
|
||||||
if (response.getStatusCodeValue() == 200 && ObjectUtil.isNotEmpty(response.getBody())) {
|
|
||||||
JSONObject object = JSONObject.parseObject(response.getBody());
|
|
||||||
if (!object.get("code").equals("0")) {
|
|
||||||
MsgException.check(true, "退款渠道调用失败");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
groupOrderInfo.setRefundNumber(groupOrderInfo.getRefundNumber() + param.getNum());
|
|
||||||
groupOrderInfo.setRefundAmount(groupOrderInfo.getRefundAmount().add(param.getRefundAmount()));
|
|
||||||
if (groupOrderInfo.getNumber() == groupOrderInfo.getRefundNumber()) {
|
|
||||||
groupOrderInfo.setRefundAble(0);
|
|
||||||
groupOrderInfo.setStatus("refund");
|
|
||||||
}
|
|
||||||
tbGroupOrderInfoMapper.update(groupOrderInfo);
|
|
||||||
return Result.success(CodeEnum.SUCCESS);
|
return Result.success(CodeEnum.SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -728,8 +731,6 @@ public class PayService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Result memberIn(String openId,String userId,String amount,String shopId,String ip) throws JsonProcessingException {
|
public Result memberIn(String openId,String userId,String amount,String shopId,String ip) throws JsonProcessingException {
|
||||||
if(ObjectUtil.isEmpty(openId)||ObjectUtil.isEmpty(userId)){
|
if(ObjectUtil.isEmpty(openId)||ObjectUtil.isEmpty(userId)){
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ public class ProductService {
|
|||||||
if (ObjectUtil.isEmpty(tbShopUser)) {
|
if (ObjectUtil.isEmpty(tbShopUser)) {
|
||||||
tbShopUser = new TbShopUser();
|
tbShopUser = new TbShopUser();
|
||||||
tbShopUser.setAmount(BigDecimal.ZERO);
|
tbShopUser.setAmount(BigDecimal.ZERO);
|
||||||
|
tbShopUser.setIsVip(Byte.parseByte("0"));
|
||||||
tbShopUser.setCreditAmount(BigDecimal.ZERO);
|
tbShopUser.setCreditAmount(BigDecimal.ZERO);
|
||||||
tbShopUser.setConsumeAmount(BigDecimal.ZERO);
|
tbShopUser.setConsumeAmount(BigDecimal.ZERO);
|
||||||
tbShopUser.setConsumeNumber(0);
|
tbShopUser.setConsumeNumber(0);
|
||||||
@@ -381,6 +382,8 @@ public class ProductService {
|
|||||||
confirmVo.setProImg(tbProduct.getCoverImg());
|
confirmVo.setProImg(tbProduct.getCoverImg());
|
||||||
confirmVo.setProName(tbProduct.getName());
|
confirmVo.setProName(tbProduct.getName());
|
||||||
|
|
||||||
|
TbShopInfo tbShopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(tbProduct.getShopId()));
|
||||||
|
confirmVo.setIsUseVip(tbShopInfo.getIsUseVip());
|
||||||
TbPurchaseNotice tbPurchaseNotice = notice.get();
|
TbPurchaseNotice tbPurchaseNotice = notice.get();
|
||||||
if (tbPurchaseNotice != null) {
|
if (tbPurchaseNotice != null) {
|
||||||
confirmVo.setAvaTime(tbPurchaseNotice.getAvailableTime());
|
confirmVo.setAvaTime(tbPurchaseNotice.getAvailableTime());
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ public class TaskScheduler {
|
|||||||
private TbUserInfoMapper userInfoMapper;
|
private TbUserInfoMapper userInfoMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private TbReleaseFlowMapper releaseFlowMapper;
|
private TbReleaseFlowMapper releaseFlowMapper;
|
||||||
|
@Autowired
|
||||||
|
private TbUserCouponsMapper userCouponsMapper;
|
||||||
//更新订单状态
|
//更新订单状态
|
||||||
// @Scheduled(fixedRate = 1000000)
|
// @Scheduled(fixedRate = 1000000)
|
||||||
public void orderStatus() throws InterruptedException {
|
public void orderStatus() throws InterruptedException {
|
||||||
@@ -130,6 +132,16 @@ public class TaskScheduler {
|
|||||||
TbUserInfo userInfo = userInfoMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getUserId()));
|
TbUserInfo userInfo = userInfoMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getUserId()));
|
||||||
TbWiningUser winingUser = new TbWiningUser(userInfo.getNickName(), orderInfo.getOrderNo(), orderInfo.getPayAmount(), "true", day);
|
TbWiningUser winingUser = new TbWiningUser(userInfo.getNickName(), orderInfo.getOrderNo(), orderInfo.getPayAmount(), "true", day);
|
||||||
tbWiningUserMapper.insert(winingUser);
|
tbWiningUserMapper.insert(winingUser);
|
||||||
|
TbUserCoupons userCoupons = new TbUserCoupons();
|
||||||
|
userCoupons.setUserId(orderInfo.getUserId());
|
||||||
|
userCoupons.setCouponsAmount(orderInfo.getOrderAmount().subtract(orderInfo.getUserCouponAmount()));
|
||||||
|
userCoupons.setStatus("0");
|
||||||
|
userCoupons.setOrderId(orderInfo.getId());
|
||||||
|
userCoupons.setCouponsPrice(userCoupons.getCouponsAmount().multiply(new BigDecimal("0.5")));
|
||||||
|
userCoupons.setCreateTime(new Date());
|
||||||
|
userCoupons.setEndTime(DateUtils.getNewDate(new Date(),3,30));
|
||||||
|
//执行插入方法
|
||||||
|
userCouponsMapper.insert(userCoupons);
|
||||||
}
|
}
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -48,6 +48,7 @@
|
|||||||
<result column="updated_at" jdbcType="BIGINT" property="updatedAt"/>
|
<result column="updated_at" jdbcType="BIGINT" property="updatedAt"/>
|
||||||
<result column="proxy_id" jdbcType="VARCHAR" property="proxyId"/>
|
<result column="proxy_id" jdbcType="VARCHAR" property="proxyId"/>
|
||||||
<result column="is_open_yhq" jdbcType="VARCHAR" property="isOpenYhq"/>
|
<result column="is_open_yhq" jdbcType="VARCHAR" property="isOpenYhq"/>
|
||||||
|
<result column="is_use_vip" jdbcType="VARCHAR" property="isUseVip"/>
|
||||||
<result column="provinces" jdbcType="VARCHAR" property="provinces"/>
|
<result column="provinces" jdbcType="VARCHAR" property="provinces"/>
|
||||||
<result column="cities" jdbcType="VARCHAR" property="cities"/>
|
<result column="cities" jdbcType="VARCHAR" property="cities"/>
|
||||||
<result column="districts" jdbcType="VARCHAR" property="districts"/>
|
<result column="districts" jdbcType="VARCHAR" property="districts"/>
|
||||||
@@ -63,7 +64,7 @@
|
|||||||
detail, lat, lng, mch_id, register_type, is_wx_ma_independent, address, city, type,
|
detail, lat, lng, mch_id, register_type, is_wx_ma_independent, address, city, type,
|
||||||
industry, industry_name, business_start_day,business_end_day,business_time, post_time, post_amount_line, on_sale, settle_type,
|
industry, industry_name, business_start_day,business_end_day,business_time, post_time, post_amount_line, on_sale, settle_type,
|
||||||
settle_time, enter_at, expire_at, status, average, order_wait_pay_minute, support_device_number,
|
settle_time, enter_at, expire_at, status, average, order_wait_pay_minute, support_device_number,
|
||||||
distribute_level, created_at, updated_at, proxy_id, shop_qrcode, tag,is_open_yhq,provinces,cities,districts
|
distribute_level, created_at, updated_at, proxy_id, shop_qrcode, tag,is_open_yhq,is_use_vip,provinces,cities,districts
|
||||||
</sql>
|
</sql>
|
||||||
<sql id="Blob_Column_List">
|
<sql id="Blob_Column_List">
|
||||||
view
|
view
|
||||||
|
|||||||
Reference in New Issue
Block a user