| @@ -7,6 +7,7 @@ import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | import com.iformall.controller.base.BaseController; | ||||
| import com.iformall.domain.po.WxCouponChannel; | import com.iformall.domain.po.WxCouponChannel; | ||||
| import com.iformall.domain.po.WxMerchant; | import com.iformall.domain.po.WxMerchant; | ||||
| import com.iformall.enums.EnumPayWay; | |||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.mapper.WxCouponChannelMapper; | import com.iformall.mapper.WxCouponChannelMapper; | ||||
| import com.iformall.mapper.WxMerchantMapper; | import com.iformall.mapper.WxMerchantMapper; | ||||
| @@ -56,7 +57,7 @@ public class WxAppinfoController extends BaseController { | |||||
| @Override | @Override | ||||
| public void run() { | public void run() { | ||||
| String param = merchant.getWeappScene(); | String param = merchant.getWeappScene(); | ||||
| ResultData resultData = qrCodeService.uploadQrcode(merchant, 1, pageUrl, param, 0, "", "", "店铺详情"); | |||||
| ResultData resultData = qrCodeService.uploadQrcode(merchant, 1, pageUrl, param, 0, "", "", "店铺详情",EnumPayWay.PAY_WAY_WECHAT); | |||||
| Map<String, String> map = (Map) resultData.data; | Map<String, String> map = (Map) resultData.data; | ||||
| if(map!=null && map.get("url") !=null) { | if(map!=null && map.get("url") !=null) { | ||||
| String url = map.get("url"); | String url = map.get("url"); | ||||
| @@ -82,7 +83,9 @@ public class WxAppinfoController extends BaseController { | |||||
| @Override | @Override | ||||
| public void run() { | public void run() { | ||||
| String param = couponChannel.getWeappScene(); | String param = couponChannel.getWeappScene(); | ||||
| ResultData resultData = qrCodeService.uploadQrcode(couponChannel,1,pageUrl,param,0,"","","券"); | |||||
| //暂时只有微信二维码,有别的码,需要加字段 | |||||
| ResultData resultData = qrCodeService.uploadQrcode(couponChannel,1,pageUrl,param,0,"","","券",EnumPayWay.PAY_WAY_WECHAT); | |||||
| Map<String,String> map = (Map)resultData.data; | Map<String,String> map = (Map)resultData.data; | ||||
| if(map!=null && map.get("url") !=null) { | if(map!=null && map.get("url") !=null) { | ||||
| String url = map.get("url"); | String url = map.get("url"); | ||||
| @@ -125,7 +128,7 @@ public class WxAppinfoController extends BaseController { | |||||
| qrCodeService.exportQrcode(request, response, | qrCodeService.exportQrcode(request, response, | ||||
| getTenantInfo(), type, pageUrl, sceneParam, | getTenantInfo(), type, pageUrl, sceneParam, | ||||
| withText, text1, text2, | withText, text1, text2, | ||||
| name); | |||||
| name,EnumPayWay.PAY_WAY_WECHAT); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error(e.getMessage()); | logger.error(e.getMessage()); | ||||
| throw new MallinkException(Result.ERROR, "下载异常"); | throw new MallinkException(Result.ERROR, "下载异常"); | ||||
| @@ -129,7 +129,9 @@ public class WxMerchantController extends BaseController { | |||||
| //加载二维码图片 | //加载二维码图片 | ||||
| String pageUrl = Constant.mainPageUrl; | String pageUrl = Constant.mainPageUrl; | ||||
| String param = "t:md:"+resultData.data; | String param = "t:md:"+resultData.data; | ||||
| ResultData resultQrCode = qrCodeService.uploadQrcode(wxMerchant,1,pageUrl,param,0,"","","店铺详情"); | |||||
| //这里暂时只有微信二维码,后续有别的二维码,再加字段 | |||||
| ResultData resultQrCode = qrCodeService.uploadQrcode(wxMerchant,1,pageUrl,param,0,"","","店铺详情",EnumPayWay.PAY_WAY_WECHAT); | |||||
| Map<String,String> map = (Map)resultQrCode.data; | Map<String,String> map = (Map)resultQrCode.data; | ||||
| if(map!=null && map.get("url") !=null) { | if(map!=null && map.get("url") !=null) { | ||||
| String url = map.get("url"); | String url = map.get("url"); | ||||
| @@ -140,7 +142,8 @@ public class WxMerchantController extends BaseController { | |||||
| return resultData; | return resultData; | ||||
| } | } | ||||
| @ApiOperation("更新商户接口") | @ApiOperation("更新商户接口") | ||||
| @PostMapping("updateMerchant") | @PostMapping("updateMerchant") | ||||
| @SystemControllerLog(description = "商户-更新") | @SystemControllerLog(description = "商户-更新") | ||||
| @@ -10,6 +10,7 @@ import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.dto.WxCouponChannelDto; | import com.iformall.domain.dto.WxCouponChannelDto; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.vo.WxCouponChannelVo; | import com.iformall.domain.vo.WxCouponChannelVo; | ||||
| import com.iformall.enums.EnumPayWay; | |||||
| import com.iformall.domain.po.base.BaseEntity; | import com.iformall.domain.po.base.BaseEntity; | ||||
| import com.iformall.domain.vo.WxCouponChannelVo; | import com.iformall.domain.vo.WxCouponChannelVo; | ||||
| import com.iformall.mapper.WxCouponChannelMapper; | import com.iformall.mapper.WxCouponChannelMapper; | ||||
| @@ -82,7 +83,9 @@ public class WxCouponChannelController extends BaseController { | |||||
| if(couponChannel!=null){ | if(couponChannel!=null){ | ||||
| String pageUrl = Constant.mainPageUrl; | String pageUrl = Constant.mainPageUrl; | ||||
| String param = couponChannel.getWeappScene(); | String param = couponChannel.getWeappScene(); | ||||
| ResultData resultDataQ = qrCodeService.uploadQrcode(couponChannel,1,pageUrl,param,0,"","","券"); | |||||
| //此处只有微信二维码,别的二维码需要加字段 | |||||
| ResultData resultDataQ = qrCodeService.uploadQrcode(couponChannel,1,pageUrl,param,0,"","","券",EnumPayWay.PAY_WAY_WECHAT); | |||||
| Map<String,String> map = (Map)resultDataQ.data; | Map<String,String> map = (Map)resultDataQ.data; | ||||
| if(map!=null && map.get("url") !=null) { | if(map!=null && map.get("url") !=null) { | ||||
| String url = map.get("url"); | String url = map.get("url"); | ||||
| @@ -10,6 +10,7 @@ import com.iformall.domain.po.base.BaseEntity; | |||||
| import com.iformall.enums.EnumCouponPasswordStatus; | import com.iformall.enums.EnumCouponPasswordStatus; | ||||
| import com.iformall.enums.EnumCouponStatus; | import com.iformall.enums.EnumCouponStatus; | ||||
| import com.iformall.enums.EnumCouponValidType; | import com.iformall.enums.EnumCouponValidType; | ||||
| import com.iformall.enums.EnumPayWay; | |||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.service.PushLimitService; | import com.iformall.service.PushLimitService; | ||||
| import com.iformall.service.WxCouponPasswordService; | import com.iformall.service.WxCouponPasswordService; | ||||
| @@ -127,7 +128,8 @@ public class WxCouponPresentController extends BaseController { | |||||
| } | } | ||||
| wxCouponPresent.setCouponName(wxCoupon.getTitle()); | wxCouponPresent.setCouponName(wxCoupon.getTitle()); | ||||
| wxCouponPresentService.add(wxCouponPresent, list, phoneSet); | |||||
| //只需要给一端发就可以了。默认给微信小程序发 | |||||
| wxCouponPresentService.add(wxCouponPresent, list, phoneSet,EnumPayWay.PAY_WAY_WECHAT); | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @@ -30,6 +30,8 @@ ADD COLUMN `pay_vendor` SMALLINT(3) NOT NULL DEFAULT 1 COMMENT '订单渠道,Enu | |||||
| UPDATE wx_coupon_order o INNER JOIN wx_pay_order po ON po.order_id = o.`id` SET o.pay_vendor = po.pay_vendor; | UPDATE wx_coupon_order o INNER JOIN wx_pay_order po ON po.order_id = o.`id` SET o.pay_vendor = po.pay_vendor; | ||||
| ---刷新完之后把DEFAULT 1 去掉 | |||||
| ALTER TABLE `wx_card_spend` | ALTER TABLE `wx_card_spend` | ||||
| ADD COLUMN `remark` VARCHAR(30) DEFAULT NULL COMMENT '备注'; | ADD COLUMN `remark` VARCHAR(30) DEFAULT NULL COMMENT '备注'; | ||||
| @@ -11,6 +11,7 @@ import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.domain.vo.WxCouponChannelVo; | import com.iformall.domain.vo.WxCouponChannelVo; | ||||
| import com.iformall.enums.EnumCampaignStatus; | import com.iformall.enums.EnumCampaignStatus; | ||||
| import com.iformall.enums.EnumCouponChannelType; | import com.iformall.enums.EnumCouponChannelType; | ||||
| import com.iformall.enums.EnumPayWay; | |||||
| import com.iformall.service.WxCampaignService; | import com.iformall.service.WxCampaignService; | ||||
| import com.iformall.service.WxCouponChannelService; | import com.iformall.service.WxCouponChannelService; | ||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| @@ -78,7 +79,7 @@ public class WxCampaignController extends BaseController { | |||||
| @ApiImplicitParams({ | @ApiImplicitParams({ | ||||
| @ApiImplicitParam(name = "sourceId", value = "", dataType = "Long", paramType = "query", required = true), | @ApiImplicitParam(name = "sourceId", value = "", dataType = "Long", paramType = "query", required = true), | ||||
| @ApiImplicitParam(name = "targetId", value = "", dataType = "Long", paramType = "query", required = true)}) | @ApiImplicitParam(name = "targetId", value = "", dataType = "Long", paramType = "query", required = true)}) | ||||
| public ResultData move(Long sourceId, Long targetId) { | |||||
| public ResultData move(Long sourceId, Long targetId,EnumPayWay payWay) { | |||||
| WxCampaign source = wxCampaignService.getById(sourceId); | WxCampaign source = wxCampaignService.getById(sourceId); | ||||
| WxCampaign target = wxCampaignService.getById(targetId); | WxCampaign target = wxCampaignService.getById(targetId); | ||||
| if (source == null || target == null) { | if (source == null || target == null) { | ||||
| @@ -84,6 +84,14 @@ public class OrderExpiringSchedule { | |||||
| @Scheduled(cron = "0 */5 * * * *?") // 每5分钟检查一次 | @Scheduled(cron = "0 */5 * * * *?") // 每5分钟检查一次 | ||||
| //@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 | //@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 | ||||
| public void orderExpireSchedule() { | public void orderExpireSchedule() { | ||||
| for (EnumPayWay payWay: EnumPayWay.values()) { | |||||
| if(null != payWay.getPlat()) { | |||||
| orderExpireSchedule(payWay); | |||||
| } | |||||
| } | |||||
| } | |||||
| private void orderExpireSchedule(EnumPayWay payWay) { | |||||
| Map dateMap = new HashMap(); | Map dateMap = new HashMap(); | ||||
| Date curDate = new Date(); | Date curDate = new Date(); | ||||
| @@ -98,7 +106,7 @@ public class OrderExpiringSchedule { | |||||
| List<WxOrder> orderCoupons = wxOrderMapper.findListOfUnpaidOrderByDate(dateMap); | List<WxOrder> orderCoupons = wxOrderMapper.findListOfUnpaidOrderByDate(dateMap); | ||||
| orderCoupons.stream().forEach( o -> { | orderCoupons.stream().forEach( o -> { | ||||
| try { | try { | ||||
| proxy.orderExpired(o,true); | |||||
| proxy.orderExpired(o,true,payWay); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error("券过期失败" + e.getMessage()); | logger.error("券过期失败" + e.getMessage()); | ||||
| } | } | ||||
| @@ -112,7 +120,7 @@ public class OrderExpiringSchedule { | |||||
| List<WxOrder> orderPresss = wxOrderMapper.findListOfCompleteUnPaidPressOrderByDate(dateMap); | List<WxOrder> orderPresss = wxOrderMapper.findListOfCompleteUnPaidPressOrderByDate(dateMap); | ||||
| orderPresss.stream().forEach( o -> { | orderPresss.stream().forEach( o -> { | ||||
| try { | try { | ||||
| proxy.orderPressExpired(o, true,true); | |||||
| proxy.orderPressExpired(o, true,true,payWay); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error("砍价券支付过期失败" + e.getMessage()); | logger.error("砍价券支付过期失败" + e.getMessage()); | ||||
| } | } | ||||
| @@ -123,7 +131,7 @@ public class OrderExpiringSchedule { | |||||
| orderPresss = wxOrderMapper.findListOfUnpaidPressOrderByDate(dateMap); | orderPresss = wxOrderMapper.findListOfUnpaidPressOrderByDate(dateMap); | ||||
| orderPresss.stream().forEach( o -> { | orderPresss.stream().forEach( o -> { | ||||
| try { | try { | ||||
| proxy.orderPressExpired(o, false,true); | |||||
| proxy.orderPressExpired(o, false,true,payWay); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error("砍价券过期失败" +e.getMessage()); | logger.error("砍价券过期失败" +e.getMessage()); | ||||
| } | } | ||||
| @@ -135,7 +143,7 @@ public class OrderExpiringSchedule { | |||||
| order.setOrderStatus(EnumOrderStatus.ORDER_STATUS_COOPERATING_UNPAID.getCode()); | order.setOrderStatus(EnumOrderStatus.ORDER_STATUS_COOPERATING_UNPAID.getCode()); | ||||
| wxOrderMapper.selectList(new QueryWrapper(order)).stream().forEach(o -> { | wxOrderMapper.selectList(new QueryWrapper(order)).stream().forEach(o -> { | ||||
| try { | try { | ||||
| proxy.orderGroupExpired((WxOrder) o,true,true); | |||||
| proxy.orderGroupExpired((WxOrder) o,true,true,payWay); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error("拼团取消失败" + e.getMessage()); | logger.error("拼团取消失败" + e.getMessage()); | ||||
| } | } | ||||
| @@ -147,7 +155,7 @@ public class OrderExpiringSchedule { | |||||
| order.setOrderStatus(EnumOrderStatus.ORDER_STATUS_COOPERATING_OVERTIME.getCode()); | order.setOrderStatus(EnumOrderStatus.ORDER_STATUS_COOPERATING_OVERTIME.getCode()); | ||||
| wxOrderMapper.selectList(new QueryWrapper(order)).stream().forEach(o -> { | wxOrderMapper.selectList(new QueryWrapper(order)).stream().forEach(o -> { | ||||
| try { | try { | ||||
| proxy.expiredAndReturnMoney((WxOrder) o,false); | |||||
| proxy.expiredAndReturnMoney((WxOrder) o,false,payWay); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error("拼团过期退款失败" + e.getMessage()); | logger.error("拼团过期退款失败" + e.getMessage()); | ||||
| } | } | ||||
| @@ -158,7 +166,7 @@ public class OrderExpiringSchedule { | |||||
| order.setOrderStatus(EnumOrderStatus.ORDER_STATUS_COOPERATING_CANCEL.getCode()); | order.setOrderStatus(EnumOrderStatus.ORDER_STATUS_COOPERATING_CANCEL.getCode()); | ||||
| wxOrderMapper.selectList(new QueryWrapper(order)).stream().forEach(o -> { | wxOrderMapper.selectList(new QueryWrapper(order)).stream().forEach(o -> { | ||||
| try { | try { | ||||
| proxy.returnMoney((WxOrder) o); | |||||
| proxy.returnMoney((WxOrder) o,payWay); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error("拼团券下架退款失败" + e.getMessage()); | logger.error("拼团券下架退款失败" + e.getMessage()); | ||||
| } | } | ||||
| @@ -168,7 +176,7 @@ public class OrderExpiringSchedule { | |||||
| order.setOrderStatus(EnumOrderStatus.ORDER_STATUS_COOPERATING_FAILD.getCode()); | order.setOrderStatus(EnumOrderStatus.ORDER_STATUS_COOPERATING_FAILD.getCode()); | ||||
| wxOrderMapper.selectList(new QueryWrapper(order)).stream().forEach(o -> { | wxOrderMapper.selectList(new QueryWrapper(order)).stream().forEach(o -> { | ||||
| try { | try { | ||||
| proxy.expiredAndReturnMoney((WxOrder) o,true); | |||||
| proxy.expiredAndReturnMoney((WxOrder) o,true,payWay); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error("参团失败退款失败" + e.getMessage()); | logger.error("参团失败退款失败" + e.getMessage()); | ||||
| } | } | ||||
| @@ -178,7 +186,7 @@ public class OrderExpiringSchedule { | |||||
| order.setOrderStatus(EnumOrderStatus.ORDER_STATUS_COOPERATING_SCHEDU_REFUND.getCode()); | order.setOrderStatus(EnumOrderStatus.ORDER_STATUS_COOPERATING_SCHEDU_REFUND.getCode()); | ||||
| wxOrderMapper.selectList(new QueryWrapper(order)).stream().forEach(o -> { | wxOrderMapper.selectList(new QueryWrapper(order)).stream().forEach(o -> { | ||||
| try { | try { | ||||
| proxy.expiredAndReturnMoney((WxOrder) o,false); | |||||
| proxy.expiredAndReturnMoney((WxOrder) o,false,payWay); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error("参团失败退款失败" + e.getMessage()); | logger.error("参团失败退款失败" + e.getMessage()); | ||||
| } | } | ||||
| @@ -187,13 +195,13 @@ public class OrderExpiringSchedule { | |||||
| } | } | ||||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | ||||
| public void expiredAndReturnMoney(WxOrder wxOrder,boolean checkRealPay) throws MallinkException, Exception { | |||||
| orderGroupExpired(wxOrder,checkRealPay,false); | |||||
| returnMoney(wxOrder); | |||||
| public void expiredAndReturnMoney(WxOrder wxOrder,boolean checkRealPay,EnumPayWay payWay) throws MallinkException, Exception { | |||||
| orderGroupExpired(wxOrder,checkRealPay,false,payWay); | |||||
| returnMoney(wxOrder,payWay); | |||||
| } | } | ||||
| public boolean wxPaySuccess(WxOrder order,boolean autoReHandle) throws MallinkException, Exception { | |||||
| public boolean wxPaySuccess(WxOrder order,boolean autoReHandle,EnumPayWay payWay) throws MallinkException, Exception { | |||||
| WxPayOrder payOrderq = new WxPayOrder(); | WxPayOrder payOrderq = new WxPayOrder(); | ||||
| payOrderq.setOrderId(order.getId()); | payOrderq.setOrderId(order.getId()); | ||||
| List<WxPayOrder> payorderlist = wxPayOrderMapper.findList(payOrderq); | List<WxPayOrder> payorderlist = wxPayOrderMapper.findList(payOrderq); | ||||
| @@ -209,15 +217,16 @@ public class OrderExpiringSchedule { | |||||
| if (null == user) { | if (null == user) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| WxCUser cuUser = new WxCUser(); | |||||
| cuUser.updateTenantInfo(order); | |||||
| cuUser.setUserId(user.getId()); | |||||
| WxCUser cUser = wxCUserMapper.selectOne(new QueryWrapper(cuUser)); | |||||
| //找不到用户,问题单,不能删 | |||||
| if (null == cUser) { | |||||
| return true; | |||||
| } | |||||
| WxAppinfo appInfo = wxAppinfoService.getByAppId(cUser.getAppId()); | |||||
| // WxCUser cuUser = new WxCUser(); | |||||
| // cuUser.updateTenantInfo(order); | |||||
| // cuUser.setUserId(user.getId()); | |||||
| // WxCUser cUser = wxCUserMapper.selectOne(new QueryWrapper(cuUser)); | |||||
| // //找不到用户,问题单,不能删 | |||||
| // if (null == cUser) { | |||||
| // return true; | |||||
| // } | |||||
| WxAppinfo appInfo = wxAppinfoService.getCAppInfo(order, payWay); | |||||
| //WxAppinfo appInfo = wxAppinfoService.getByAppId(cUser.getAppId()); | |||||
| //找不到appInfo,问题单,不能删 | //找不到appInfo,问题单,不能删 | ||||
| if(appInfo == null) { | if(appInfo == null) { | ||||
| return true; | return true; | ||||
| @@ -242,9 +251,9 @@ public class OrderExpiringSchedule { | |||||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | ||||
| public void orderExpired(WxOrder order,boolean checkRealPay) throws MallinkException, Exception { | |||||
| public void orderExpired(WxOrder order,boolean checkRealPay,EnumPayWay payWay) throws MallinkException, Exception { | |||||
| if (checkRealPay) { | if (checkRealPay) { | ||||
| if (wxPaySuccess(order,true)) { | |||||
| if (wxPaySuccess(order,true,payWay)) { | |||||
| return; | return; | ||||
| } | } | ||||
| } | } | ||||
| @@ -252,7 +261,7 @@ public class OrderExpiringSchedule { | |||||
| wxOrderService.stockBack(order); | wxOrderService.stockBack(order); | ||||
| // 微信 关单 | // 微信 关单 | ||||
| wxOrderService.orderClose(order); | |||||
| wxOrderService.orderClose(order,payWay); | |||||
| // 订单状态更改 | // 订单状态更改 | ||||
| WxOrder updateOrder = new WxOrder(); | WxOrder updateOrder = new WxOrder(); | ||||
| @@ -265,9 +274,9 @@ public class OrderExpiringSchedule { | |||||
| } | } | ||||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | ||||
| public void orderPressExpired(WxOrder order, boolean payExpired,boolean checkRealPay) throws MallinkException, Exception { | |||||
| public void orderPressExpired(WxOrder order, boolean payExpired,boolean checkRealPay,EnumPayWay payWay) throws MallinkException, Exception { | |||||
| if (checkRealPay) { | if (checkRealPay) { | ||||
| if (wxPaySuccess(order,true)) { | |||||
| if (wxPaySuccess(order,true,payWay)) { | |||||
| return; | return; | ||||
| } | } | ||||
| } | } | ||||
| @@ -291,9 +300,9 @@ public class OrderExpiringSchedule { | |||||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | ||||
| public void orderGroupExpired(WxOrder order,boolean checkRealPay,boolean stockBack) throws MallinkException, Exception { | |||||
| public void orderGroupExpired(WxOrder order,boolean checkRealPay,boolean stockBack,EnumPayWay payWay) throws MallinkException, Exception { | |||||
| if (checkRealPay) { | if (checkRealPay) { | ||||
| if (wxPaySuccess(order,true)) { | |||||
| if (wxPaySuccess(order,true,payWay)) { | |||||
| return; | return; | ||||
| } | } | ||||
| } | } | ||||
| @@ -310,7 +319,7 @@ public class OrderExpiringSchedule { | |||||
| wxOrderService.stockBack(order); | wxOrderService.stockBack(order); | ||||
| } | } | ||||
| // 微信 关单 | // 微信 关单 | ||||
| wxOrderService.orderClose(updateOrder); | |||||
| wxOrderService.orderClose(updateOrder,payWay); | |||||
| logger.info("拼团订单: " + order.getId() + " create at " + order.getCreateDate() + " expired at " + curDate); | logger.info("拼团订单: " + order.getId() + " create at " + order.getCreateDate() + " expired at " + curDate); | ||||
| } | } | ||||
| @@ -321,9 +330,9 @@ public class OrderExpiringSchedule { | |||||
| * @throws MallinkException | * @throws MallinkException | ||||
| */ | */ | ||||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | ||||
| public void returnMoney(WxOrder order) throws MallinkException, Exception { | |||||
| public void returnMoney(WxOrder order,EnumPayWay payWay) throws MallinkException, Exception { | |||||
| //支付成功的才退款 | //支付成功的才退款 | ||||
| if (!wxPaySuccess(order,false)) { | |||||
| if (!wxPaySuccess(order,false,payWay)) { | |||||
| return; | return; | ||||
| } | } | ||||
| @@ -3,6 +3,7 @@ package com.iformall.service; | |||||
| import com.amazonaws.services.s3.model.ObjectMetadata; | import com.amazonaws.services.s3.model.ObjectMetadata; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.enums.EnumPayWay; | |||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import org.springframework.web.bind.annotation.RequestBody; | import org.springframework.web.bind.annotation.RequestBody; | ||||
| @@ -14,14 +15,14 @@ import java.util.Map; | |||||
| @Service | @Service | ||||
| public interface QrCodeService { | public interface QrCodeService { | ||||
| void downQrCode(TenantEntity tenantEntity, HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, Object> params) throws MallinkException; | |||||
| void downQrCode(TenantEntity tenantEntity, HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, Object> params,EnumPayWay payWay) throws MallinkException; | |||||
| ResultData exportQrcode(HttpServletRequest request, HttpServletResponse response, | ResultData exportQrcode(HttpServletRequest request, HttpServletResponse response, | ||||
| TenantEntity tenantEntity, int type, String pageUrl, String sceneParam, | TenantEntity tenantEntity, int type, String pageUrl, String sceneParam, | ||||
| int withText, String text1, String text2, | int withText, String text1, String text2, | ||||
| String name); | |||||
| String name,EnumPayWay payWay); | |||||
| ResultData uploadQrcode(TenantEntity tenantEntity, int type, String pageUrl, String sceneParam, | ResultData uploadQrcode(TenantEntity tenantEntity, int type, String pageUrl, String sceneParam, | ||||
| int withText, String text1, String text2, | int withText, String text1, String text2, | ||||
| String name); | |||||
| String name,EnumPayWay payWay); | |||||
| ResultData awsUpload(InputStream inputStream, ObjectMetadata metadata, String fileName, TenantEntity tenantEntity); | ResultData awsUpload(InputStream inputStream, ObjectMetadata metadata, String fileName, TenantEntity tenantEntity); | ||||
| } | } | ||||
| @@ -3,6 +3,7 @@ package com.iformall.service; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.WxActivity; | import com.iformall.domain.po.WxActivity; | ||||
| import com.iformall.enums.EnumPayWay; | |||||
| import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
| @@ -4,6 +4,7 @@ import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.WxAppinfo; | import com.iformall.domain.po.WxAppinfo; | ||||
| import com.iformall.domain.po.WxProjectConfig; | import com.iformall.domain.po.WxProjectConfig; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.enums.EnumPayWay; | |||||
| import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
| import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
| @@ -60,7 +61,7 @@ public interface WxAppinfoService { | |||||
| * 获取c端小程序信息 | * 获取c端小程序信息 | ||||
| * @return | * @return | ||||
| */ | */ | ||||
| WxAppinfo getCAppInfo(TenantEntity tenantEntity); | |||||
| WxAppinfo getCAppInfo(TenantEntity tenantEntity,EnumPayWay payWay); | |||||
| /** | /** | ||||
| * 保存或更新实体 | * 保存或更新实体 | ||||
| @@ -4,6 +4,7 @@ import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.WxCampaign; | import com.iformall.domain.po.WxCampaign; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.enums.EnumPayWay; | |||||
| import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
| @@ -6,6 +6,7 @@ import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.domain.po.WxCouponChannel; | import com.iformall.domain.po.WxCouponChannel; | ||||
| import com.iformall.domain.vo.WxCouponCVo; | import com.iformall.domain.vo.WxCouponCVo; | ||||
| import com.iformall.domain.vo.WxCouponChannelVo; | import com.iformall.domain.vo.WxCouponChannelVo; | ||||
| import com.iformall.enums.EnumPayWay; | |||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.List; | import java.util.List; | ||||
| @@ -4,6 +4,7 @@ import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.WxCouponPassword; | import com.iformall.domain.po.WxCouponPassword; | ||||
| import com.iformall.domain.po.WxCouponPresent; | import com.iformall.domain.po.WxCouponPresent; | ||||
| import com.iformall.enums.EnumPayWay; | |||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Set; | import java.util.Set; | ||||
| @@ -18,6 +19,6 @@ public interface WxCouponPresentService { | |||||
| WxCouponPresent findById(Long id); | WxCouponPresent findById(Long id); | ||||
| ResultData add(WxCouponPresent wxCouponPresent, List<WxCouponPassword> list, Set<String> phoneSet); | |||||
| ResultData add(WxCouponPresent wxCouponPresent, List<WxCouponPassword> list, Set<String> phoneSet,EnumPayWay payWay); | |||||
| } | } | ||||
| @@ -4,6 +4,7 @@ import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.WxGame; | import com.iformall.domain.po.WxGame; | ||||
| import com.iformall.domain.po.WxGameActionLog; | import com.iformall.domain.po.WxGameActionLog; | ||||
| import com.iformall.enums.EnumPayWay; | |||||
| public interface WxGameService { | public interface WxGameService { | ||||
| @@ -112,7 +112,7 @@ public interface WxOrderService { | |||||
| /** | /** | ||||
| * 订单关单 | * 订单关单 | ||||
| */ | */ | ||||
| ResultData orderClose(WxOrder order); | |||||
| ResultData orderClose(WxOrder order,EnumPayWay payWay); | |||||
| /** | /** | ||||
| * 根据Id获得实体 | * 根据Id获得实体 | ||||
| @@ -3,6 +3,7 @@ package com.iformall.service; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.WxTopic; | import com.iformall.domain.po.WxTopic; | ||||
| import com.iformall.enums.EnumPayWay; | |||||
| public interface WxTopicService { | public interface WxTopicService { | ||||
| @@ -18,11 +18,13 @@ import com.iformall.common.ResultData; | |||||
| import com.iformall.config.AwsProperty; | import com.iformall.config.AwsProperty; | ||||
| import com.iformall.domain.po.MallResource; | import com.iformall.domain.po.MallResource; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.enums.EnumPayWay; | |||||
| import com.iformall.domain.po.WxAppinfo; | import com.iformall.domain.po.WxAppinfo; | ||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.service.MallResourceService; | import com.iformall.service.MallResourceService; | ||||
| import com.iformall.service.QrCodeService; | import com.iformall.service.QrCodeService; | ||||
| import com.iformall.service.WxAppinfoService; | import com.iformall.service.WxAppinfoService; | ||||
| import com.iformall.service.pay.PayServiceFactory; | |||||
| import com.iformall.service.wechat.FmOpenService; | import com.iformall.service.wechat.FmOpenService; | ||||
| import com.iformall.utils.MaUtil; | import com.iformall.utils.MaUtil; | ||||
| import com.iformall.utils.QRCodeUtils; | import com.iformall.utils.QRCodeUtils; | ||||
| @@ -47,8 +49,6 @@ public class QrCodeServiceImpl implements QrCodeService { | |||||
| @Autowired | @Autowired | ||||
| private WxAppinfoService wxAppinfoService; | private WxAppinfoService wxAppinfoService; | ||||
| @Autowired | @Autowired | ||||
| private FmOpenService openService; | |||||
| @Autowired | |||||
| private boolean isFmOpen; | private boolean isFmOpen; | ||||
| @Autowired | @Autowired | ||||
| private AwsProperty awsProperty; | private AwsProperty awsProperty; | ||||
| @@ -56,6 +56,8 @@ public class QrCodeServiceImpl implements QrCodeService { | |||||
| private MallResourceService mallResourceService; | private MallResourceService mallResourceService; | ||||
| @Autowired | @Autowired | ||||
| private String fmUploadDir; | private String fmUploadDir; | ||||
| @Autowired | |||||
| private PayServiceFactory payServiceFactory; | |||||
| private AmazonS3 s3 = null; | private AmazonS3 s3 = null; | ||||
| @@ -126,7 +128,7 @@ public class QrCodeServiceImpl implements QrCodeService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void downQrCode(TenantEntity tenantEntity, HttpServletRequest request, HttpServletResponse response, Map<String, Object> params) throws MallinkException { | |||||
| public void downQrCode(TenantEntity tenantEntity, HttpServletRequest request, HttpServletResponse response, Map<String, Object> params,EnumPayWay payWay) throws MallinkException { | |||||
| String name = (String) params.get("name"); | String name = (String) params.get("name"); | ||||
| String pageUrl = (String) params.get("pageUrl"); | String pageUrl = (String) params.get("pageUrl"); | ||||
| String sceneParam = (String) params.get("sceneParam"); | String sceneParam = (String) params.get("sceneParam"); | ||||
| @@ -152,7 +154,7 @@ public class QrCodeServiceImpl implements QrCodeService { | |||||
| exportQrcode(request, response, | exportQrcode(request, response, | ||||
| tenantEntity, type, pageUrl, sceneParam, | tenantEntity, type, pageUrl, sceneParam, | ||||
| withText, text1, text2, | withText, text1, text2, | ||||
| name); | |||||
| name,payWay); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error(e.getMessage()); | logger.error(e.getMessage()); | ||||
| throw new MallinkException(Result.ERROR, "下载异常"); | throw new MallinkException(Result.ERROR, "下载异常"); | ||||
| @@ -163,28 +165,10 @@ public class QrCodeServiceImpl implements QrCodeService { | |||||
| public ResultData exportQrcode(HttpServletRequest request, HttpServletResponse response, | public ResultData exportQrcode(HttpServletRequest request, HttpServletResponse response, | ||||
| TenantEntity tenantEntity, int type, String pageUrl, String sceneParam, | TenantEntity tenantEntity, int type, String pageUrl, String sceneParam, | ||||
| int withText, String text1, String text2, | int withText, String text1, String text2, | ||||
| String name) { | |||||
| String name,EnumPayWay payWay) { | |||||
| // type 0 有限二维码, 1 无限制二维码 | // type 0 有限二维码, 1 无限制二维码 | ||||
| // withText 0 不带字 1. 带下面的字,2 带下面的两行字 | // withText 0 不带字 1. 带下面的字,2 带下面的两行字 | ||||
| WxAppinfo appinfo = wxAppinfoService.getCAppInfo(tenantEntity); | |||||
| boolean autoColor = false; | |||||
| boolean isHyaline = true; | |||||
| WxMaCodeLineColor color = new WxMaCodeLineColor("0", "0", "0"); | |||||
| WxMaService wxMaService; | |||||
| if(isFmOpen) { | |||||
| wxMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appinfo.getAppId()); | |||||
| } else { | |||||
| wxMaService = MaUtil.getWeappService(appinfo); | |||||
| } | |||||
| String pathStr = ""; | |||||
| if (StringUtils.isNotBlank(sceneParam)) { | |||||
| pathStr = pageUrl + "?scene="+sceneParam; | |||||
| } else { | |||||
| pathStr = pageUrl; | |||||
| } | |||||
| WxAppinfo appinfo = wxAppinfoService.getCAppInfo(tenantEntity,payWay); | |||||
| String filepath = fmUploadDir; | String filepath = fmUploadDir; | ||||
| String fileName = name + ".png"; | String fileName = name + ".png"; | ||||
| @@ -197,16 +181,9 @@ public class QrCodeServiceImpl implements QrCodeService { | |||||
| pDest.mkdirs(); | pDest.mkdirs(); | ||||
| } | } | ||||
| try { | try { | ||||
| if(type == 0) { | |||||
| final File codeFile = wxMaService.getQrcodeService().createQrcode(pathStr, QRCodeUtils.QR_WIDTH); | |||||
| copyFileToDest(withText, text1, text2, destPath1, dest, codeFile); | |||||
| org.apache.commons.io.FileUtils.forceDelete(codeFile); | |||||
| } else { | |||||
| final File codeFile = wxMaService.getQrcodeService().createWxaCodeUnlimit(sceneParam, pageUrl, QRCodeUtils.QR_WIDTH, autoColor, color, isHyaline); | |||||
| copyFileToDest(withText, text1, text2, destPath1, dest, codeFile); | |||||
| org.apache.commons.io.FileUtils.forceDelete(codeFile); | |||||
| } | |||||
| File codeFile = payServiceFactory.getPayAdapterService(payWay.getCode()).getQrcode(appinfo, pageUrl, type, sceneParam); | |||||
| copyFileToDest(withText, text1, text2, destPath1, dest, codeFile); | |||||
| org.apache.commons.io.FileUtils.forceDelete(codeFile); | |||||
| } catch (WxErrorException e) { | } catch (WxErrorException e) { | ||||
| logger.error(e.getMessage()); | logger.error(e.getMessage()); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| @@ -225,28 +202,10 @@ public class QrCodeServiceImpl implements QrCodeService { | |||||
| @Override | @Override | ||||
| public ResultData uploadQrcode(TenantEntity tenantEntity, int type, String pageUrl, String sceneParam, | public ResultData uploadQrcode(TenantEntity tenantEntity, int type, String pageUrl, String sceneParam, | ||||
| int withText, String text1, String text2, | int withText, String text1, String text2, | ||||
| String name) { | |||||
| String name,EnumPayWay payWay) { | |||||
| // type 0 有限二维码, 1 无限制二维码 | // type 0 有限二维码, 1 无限制二维码 | ||||
| // withText 0 不带字 1. 带下面的字,2 带下面的两行字 | // withText 0 不带字 1. 带下面的字,2 带下面的两行字 | ||||
| WxAppinfo appinfo = wxAppinfoService.getCAppInfo(tenantEntity); | |||||
| boolean autoColor = false; | |||||
| boolean isHyaline = true; | |||||
| WxMaCodeLineColor color = new WxMaCodeLineColor("0", "0", "0"); | |||||
| WxMaService wxMaService; | |||||
| if(isFmOpen) { | |||||
| wxMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appinfo.getAppId()); | |||||
| } else { | |||||
| wxMaService = MaUtil.getWeappService(appinfo); | |||||
| } | |||||
| String pathStr = ""; | |||||
| if (StringUtils.isNotBlank(sceneParam)) { | |||||
| pathStr = pageUrl + "?scene="+sceneParam; | |||||
| } else { | |||||
| pathStr = pageUrl; | |||||
| } | |||||
| WxAppinfo appinfo = wxAppinfoService.getCAppInfo(tenantEntity,payWay); | |||||
| String filepath = fmUploadDir; | String filepath = fmUploadDir; | ||||
| String fileName = name + ".png"; | String fileName = name + ".png"; | ||||
| @@ -259,16 +218,9 @@ public class QrCodeServiceImpl implements QrCodeService { | |||||
| pDest.mkdirs(); | pDest.mkdirs(); | ||||
| } | } | ||||
| try { | try { | ||||
| if(type == 0) { | |||||
| final File codeFile = wxMaService.getQrcodeService().createQrcode(pathStr, QRCodeUtils.QR_WIDTH); | |||||
| copyFileToDest(withText, text1, text2, destPath1, dest, codeFile); | |||||
| org.apache.commons.io.FileUtils.forceDelete(codeFile); | |||||
| } else { | |||||
| final File codeFile = wxMaService.getQrcodeService().createWxaCodeUnlimit(sceneParam, pageUrl, QRCodeUtils.QR_WIDTH, autoColor, color, isHyaline); | |||||
| copyFileToDest(withText, text1, text2, destPath1, dest, codeFile); | |||||
| org.apache.commons.io.FileUtils.forceDelete(codeFile); | |||||
| } | |||||
| File codeFile = payServiceFactory.getPayAdapterService(payWay.getCode()).getQrcode(appinfo, pageUrl, type, sceneParam); | |||||
| copyFileToDest(withText, text1, text2, destPath1, dest, codeFile); | |||||
| org.apache.commons.io.FileUtils.forceDelete(codeFile); | |||||
| } catch (WxErrorException e) { | } catch (WxErrorException e) { | ||||
| logger.error(e.getMessage()); | logger.error(e.getMessage()); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| @@ -8,6 +8,7 @@ import com.iformall.domain.po.WxAppinfo; | |||||
| import com.iformall.domain.po.WxProjectConfig; | import com.iformall.domain.po.WxProjectConfig; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.enums.EnumAppType; | import com.iformall.enums.EnumAppType; | ||||
| import com.iformall.enums.EnumPayWay; | |||||
| import com.iformall.mapper.WxAppinfoMapper; | import com.iformall.mapper.WxAppinfoMapper; | ||||
| import com.iformall.service.WxAppinfoService; | import com.iformall.service.WxAppinfoService; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| @@ -25,9 +26,10 @@ public class WxAppinfoServiceImpl implements WxAppinfoService { | |||||
| WxAppinfoMapper wxAppinfoMapper; | WxAppinfoMapper wxAppinfoMapper; | ||||
| @Override | @Override | ||||
| public WxAppinfo getCAppInfo(TenantEntity tenantEntity) { | |||||
| public WxAppinfo getCAppInfo(TenantEntity tenantEntity,EnumPayWay payWay) { | |||||
| WxAppinfo appInfo = null; | WxAppinfo appInfo = null; | ||||
| WxAppinfo appinfoQ = new WxAppinfo(); | WxAppinfo appinfoQ = new WxAppinfo(); | ||||
| appinfoQ.setPlat(payWay.getPlat().getCode()); | |||||
| appinfoQ.updateTenantInfo(tenantEntity); | appinfoQ.updateTenantInfo(tenantEntity); | ||||
| appinfoQ.setType(EnumAppType.C.getCode()); | appinfoQ.setType(EnumAppType.C.getCode()); | ||||
| List<WxAppinfo> appList = wxAppinfoMapper.selectList(new QueryWrapper(appinfoQ)); | List<WxAppinfo> appList = wxAppinfoMapper.selectList(new QueryWrapper(appinfoQ)); | ||||
| @@ -271,7 +271,9 @@ public class WxCampaignServiceImpl implements WxCampaignService { | |||||
| couponChannel.setId(wxCouponChannel.getId()); | couponChannel.setId(wxCouponChannel.getId()); | ||||
| couponChannel.setType(wxCouponChannel.getType()); | couponChannel.setType(wxCouponChannel.getType()); | ||||
| String param = couponChannel.getWeappScene(); | String param = couponChannel.getWeappScene(); | ||||
| ResultData resultDataQ = qrCodeService.uploadQrcode(wxCoupon,1,pageUrl,param,0,"","","券"); | |||||
| //此处只有微信二维码,如果需要彼得二维码,需要加字段 | |||||
| ResultData resultDataQ = qrCodeService.uploadQrcode(wxCoupon,1,pageUrl,param,0,"","","券",EnumPayWay.PAY_WAY_WECHAT); | |||||
| Map<String,String> map = (Map)resultDataQ.data; | Map<String,String> map = (Map)resultDataQ.data; | ||||
| if(map!=null && map.get("url") !=null) { | if(map!=null && map.get("url") !=null) { | ||||
| String url = map.get("url"); | String url = map.get("url"); | ||||
| @@ -292,7 +292,9 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||||
| couponChannel.setId(vo.getId()); | couponChannel.setId(vo.getId()); | ||||
| couponChannel.setType(vo.getType()); | couponChannel.setType(vo.getType()); | ||||
| String param = couponChannel.getWeappScene(); | String param = couponChannel.getWeappScene(); | ||||
| ResultData resultDataQ = qrCodeService.uploadQrcode(wxCoupon,1,pageUrl,param,0,"","","券"); | |||||
| //此处只有微信二维码 | |||||
| ResultData resultDataQ = qrCodeService.uploadQrcode(wxCoupon,1,pageUrl,param,0,"","","券",EnumPayWay.PAY_WAY_WECHAT); | |||||
| Map<String,String> map = (Map)resultDataQ.data; | Map<String,String> map = (Map)resultDataQ.data; | ||||
| if(map!=null && map.get("url") !=null) { | if(map!=null && map.get("url") !=null) { | ||||
| String url = map.get("url"); | String url = map.get("url"); | ||||
| @@ -626,7 +626,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR); | throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR); | ||||
| } | } | ||||
| WxAppinfo wxAppinfo = wxAppinfoService.getCAppInfo(couponOrder); | |||||
| WxAppinfo wxAppinfo = wxAppinfoService.getCAppInfo(couponOrder,EnumPayWay.getEnum(couponOrder.getPayVendor())); | |||||
| WxPayAccount payAccount = wxPayAccountMapper.selectById(wxAppinfo.getPayId()); | WxPayAccount payAccount = wxPayAccountMapper.selectById(wxAppinfo.getPayId()); | ||||
| Integer subsidyNum = coupon.getSubsidyNum(); | Integer subsidyNum = coupon.getSubsidyNum(); | ||||
| @@ -54,7 +54,7 @@ public class WxCouponPresentServiceImpl implements WxCouponPresentService { | |||||
| @Async | @Async | ||||
| @Override | @Override | ||||
| public ResultData add(WxCouponPresent record, List<WxCouponPassword> list, Set<String> phoneSet) { | |||||
| public ResultData add(WxCouponPresent record, List<WxCouponPassword> list, Set<String> phoneSet,EnumPayWay payWay) { | |||||
| //添加记录 | //添加记录 | ||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| long id = idWorker.nextId(); | long id = idWorker.nextId(); | ||||
| @@ -62,7 +62,7 @@ public class WxCouponPresentServiceImpl implements WxCouponPresentService { | |||||
| record.setSendAmount(phoneSet.size()); | record.setSendAmount(phoneSet.size()); | ||||
| wxCouponPresentMapper.insert(record); | wxCouponPresentMapper.insert(record); | ||||
| //小程序 | //小程序 | ||||
| WxAppinfo appInfo = wxAppinfoService.getCAppInfo(record); | |||||
| WxAppinfo appInfo = wxAppinfoService.getCAppInfo(record,payWay); | |||||
| String title = record.getCouponName(); | String title = record.getCouponName(); | ||||
| String name = appInfo.getName(); | String name = appInfo.getName(); | ||||
| List<WxCouponPassword> tempList = new ArrayList<>(); | List<WxCouponPassword> tempList = new ArrayList<>(); | ||||
| @@ -418,7 +418,7 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { | |||||
| String phone = user.getPhone(); | String phone = user.getPhone(); | ||||
| //小程序名称 | //小程序名称 | ||||
| WxAppinfo appInfo = wxAppinfoService.getCAppInfo(tenantEntity); | |||||
| WxAppinfo appInfo = wxAppinfoService.getCAppInfo(tenantEntity,EnumPayWay.getEnum(couponOrder.getPayVendor())); | |||||
| String appName = appInfo.getName(); | String appName = appInfo.getName(); | ||||
| Map<String, String> msgReplaceMap = new HashMap(); | Map<String, String> msgReplaceMap = new HashMap(); | ||||
| msgReplaceMap.put("title", title); | msgReplaceMap.put("title", title); | ||||
| @@ -16,6 +16,7 @@ import com.iformall.enums.EnumCouponChannelStatus; | |||||
| import com.iformall.enums.EnumCouponChannelType; | import com.iformall.enums.EnumCouponChannelType; | ||||
| import com.iformall.enums.EnumCouponStatus; | import com.iformall.enums.EnumCouponStatus; | ||||
| import com.iformall.enums.EnumGameStatus; | import com.iformall.enums.EnumGameStatus; | ||||
| import com.iformall.enums.EnumPayWay; | |||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.mapper.WxCouponChannelMapper; | import com.iformall.mapper.WxCouponChannelMapper; | ||||
| import com.iformall.mapper.WxCouponOrderMapper; | import com.iformall.mapper.WxCouponOrderMapper; | ||||
| @@ -336,7 +337,9 @@ public class WxGameServiceImpl implements WxGameService { | |||||
| couponChannel.setId(wxCouponChannel.getId()); | couponChannel.setId(wxCouponChannel.getId()); | ||||
| couponChannel.setType(wxCouponChannel.getType()); | couponChannel.setType(wxCouponChannel.getType()); | ||||
| String param = couponChannel.getWeappScene(); | String param = couponChannel.getWeappScene(); | ||||
| ResultData resultDataQ = qrCodeService.uploadQrcode(wxCoupon,1,pageUrl,param,0,"","","券"); | |||||
| //暂时只有微信二维码,如果有别的二维码,则需要别的字段 | |||||
| ResultData resultDataQ = qrCodeService.uploadQrcode(wxCoupon,1,pageUrl,param,0,"","","券",EnumPayWay.PAY_WAY_WECHAT); | |||||
| Map<String,String> map = (Map)resultDataQ.data; | Map<String,String> map = (Map)resultDataQ.data; | ||||
| if(map!=null && map.get("url") !=null) { | if(map!=null && map.get("url") !=null) { | ||||
| String url = map.get("url"); | String url = map.get("url"); | ||||
| @@ -1629,9 +1629,9 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| * 微信关闭订单 | * 微信关闭订单 | ||||
| */ | */ | ||||
| @Override | @Override | ||||
| public ResultData orderClose(WxOrder order) { | |||||
| public ResultData orderClose(WxOrder order,EnumPayWay payWay) { | |||||
| // 1. get c appid | // 1. get c appid | ||||
| WxAppinfo appInfo = wxAppinfoService.getCAppInfo(order); | |||||
| WxAppinfo appInfo = wxAppinfoService.getCAppInfo(order,payWay); | |||||
| // 2. get pay order | // 2. get pay order | ||||
| WxPayOrder payOrderQ = new WxPayOrder(); | WxPayOrder payOrderQ = new WxPayOrder(); | ||||
| payOrderQ.updateTenantInfo(order); | payOrderQ.updateTenantInfo(order); | ||||
| @@ -105,14 +105,6 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| "\"ORDERNOTEXIST\":{\"detail\":\"此交易订单号不存在\",\"reason\":\"查询系统中不存在此交易订单号\",\"resolution\":\"该API只能查提交支付交易返回成功的订单,请商户检查需要查询的订单号是否正确\"},\n" + | "\"ORDERNOTEXIST\":{\"detail\":\"此交易订单号不存在\",\"reason\":\"查询系统中不存在此交易订单号\",\"resolution\":\"该API只能查提交支付交易返回成功的订单,请商户检查需要查询的订单号是否正确\"},\n" + | ||||
| "\"SYSTEMERROR\":{\"detail\":\"系统错误\t\",\"reason\":\"后台系统返回错误\",\"resolution\":\"系统异常,请再调用发起查询\"}}"); | "\"SYSTEMERROR\":{\"detail\":\"系统错误\t\",\"reason\":\"后台系统返回错误\",\"resolution\":\"系统异常,请再调用发起查询\"}}"); | ||||
| JSONObject errorMapClose = JSON.parseObject("{" + | |||||
| "\"ORDERPAID\":{\"detail\":\"订单已支付\",\"reason\":\"订单已支付,不能发起关单\",\"resolution\":\"订单已支付,不能发起关单,请当作已支付的正常交易\"}," + | |||||
| "\"SYSTEMERROR\":{\"detail\":\"系统错误\",\"reason\":\"系统错误\",\"resolution\":\"系统异常,请重新调用该API\"}," + | |||||
| "\"ORDERCLOSED\":{\"detail\":\"订单已关闭\",\"reason\":\"订单已关闭,无法重复关闭\",\"resolution\":\"订单已关闭,无需继续调用\"}," + | |||||
| "\"SIGNERROR\":{\"detail\":\"签名错误\",\"reason\":\"参数签名结果不正确\",\"resolution\":\"请检查签名参数和方法是否都符合签名算法要求\"}," + | |||||
| "\"REQUIRE_POST_METHOD\":{\"detail\":\"请使用post方法\",\"reason\":\"未使用post传递参数\",\"resolution\":\"请检查请求参数是否通过post方法提交\"}," + | |||||
| "\"XML_FORMAT_ERROR\":{\"detail\":\"XML格式错误\t\",\"reason\":\"XML格式错误\",\"reason\":\"请检查XML参数格式是否正确\"}}"); | |||||
| //方法必须为public AopContext.currentProxy() | //方法必须为public AopContext.currentProxy() | ||||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | ||||
| @Override | @Override | ||||
| @@ -402,7 +394,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| public ResultData createMicroPayOrder(WxMerchantBUser user, WxPayOrder record, EnumPayWay payWay,PayExtraParam params) { | public ResultData createMicroPayOrder(WxMerchantBUser user, WxPayOrder record, EnumPayWay payWay,PayExtraParam params) { | ||||
| final IdWorker idworker = IdWorker.get(); | final IdWorker idworker = IdWorker.get(); | ||||
| WxAppinfo appInfo = wxAppinfoService.getCAppInfo(user); | |||||
| WxAppinfo appInfo = wxAppinfoService.getCAppInfo(user,payWay); | |||||
| if (null == params) { | if (null == params) { | ||||
| params = new PayExtraParam(); | params = new PayExtraParam(); | ||||
| } | } | ||||
| @@ -529,7 +521,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), "Order not found"); | return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), "Order not found"); | ||||
| } | } | ||||
| WxAppinfo appInfo = wxAppinfoService.getCAppInfo(record); | |||||
| WxAppinfo appInfo = wxAppinfoService.getCAppInfo(record,payWay); | |||||
| PayAdapterService payService = payServiceFactory.getPayAdapterService(payWay.getCode()); | PayAdapterService payService = payServiceFactory.getPayAdapterService(payWay.getCode()); | ||||
| WxPayAccount payAccount = wxPayAccountMapper.selectById(appInfo.getPayId()); | WxPayAccount payAccount = wxPayAccountMapper.selectById(appInfo.getPayId()); | ||||
| PayQueryAdapterResult apiResult = payService.queryPayStatus(record, order, appInfo, payAccount); | PayQueryAdapterResult apiResult = payService.queryPayStatus(record, order, appInfo, payAccount); | ||||
| @@ -595,167 +587,40 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| } | } | ||||
| } | } | ||||
| private String wechatPayOrderClose(WxAppinfo appInfo, WxPayOrder record) { | |||||
| // get payAccount | |||||
| WxPayAccount payAccount = wxPayAccountMapper.selectById(appInfo.getPayId()); | |||||
| if (payAccount.getType() == EnumPayMode.MCH.getCode()) { | |||||
| // 普通商户号模式 | |||||
| WxPayOrderQ payOrderC = new WxPayOrderQ(); | |||||
| String noncestr = Utility.generate32UUID(); | |||||
| payOrderC.setAppid(appInfo.getAppId()); | |||||
| payOrderC.setMch_id(payAccount.getMchId()); | |||||
| payOrderC.setNonce_str(noncestr); | |||||
| payOrderC.setOut_trade_no(record.getPayOrderNo()); | |||||
| try { | |||||
| Map map = BeanUtils.toStringMap(payOrderC); | |||||
| payOrderC.setSign(WxPayment.createSign(map, payAccount.getApiKey())); | |||||
| map = BeanUtils.toStringMap(payOrderC); | |||||
| String response = WxPay.closeOrder(map); | |||||
| logger.info("request:" + map.toString() + "\nresponse:" + response); | |||||
| return response; | |||||
| } catch (RuntimeException e) { | |||||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||||
| } catch (Exception e) { | |||||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||||
| } | |||||
| } else { | |||||
| // 服务商模式 | |||||
| WxPayOrderSQ payOrderSC = new WxPayOrderSQ(); | |||||
| String noncestr = Utility.generate32UUID(); | |||||
| payOrderSC.setAppid(appInfo.getParentAppId()); | |||||
| payOrderSC.setSub_appid(appInfo.getAppId()); | |||||
| payOrderSC.setMch_id(payAccount.getMchId()); | |||||
| payOrderSC.setSub_mch_id(payAccount.getSubMchId()); | |||||
| payOrderSC.setNonce_str(noncestr); | |||||
| payOrderSC.setOut_trade_no(record.getPayOrderNo()); | |||||
| payOrderSC.setSign_type("HMAC-SHA256"); | |||||
| try { | |||||
| Map map = BeanUtils.toStringMap(payOrderSC); | |||||
| payOrderSC.setSign(WxPayment.createSignHMAC(map, payAccount.getApiKey())); | |||||
| map = BeanUtils.toStringMap(payOrderSC); | |||||
| String response = WxPay.closeOrder(map); | |||||
| logger.info("request:" + map.toString() + "\nresponse:" + response); | |||||
| return response; | |||||
| } catch (RuntimeException e) { | |||||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||||
| } catch (Exception e) { | |||||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||||
| } | |||||
| } | |||||
| } | |||||
| /** | /** | ||||
| * 微信关闭支付订单 | * 微信关闭支付订单 | ||||
| */ | */ | ||||
| @Override | @Override | ||||
| public ResultData payOrderClose(WxAppinfo appInfo, WxPayOrder record) { | public ResultData payOrderClose(WxAppinfo appInfo, WxPayOrder record) { | ||||
| try { | |||||
| String response = wechatPayOrderClose(appInfo, record); | |||||
| logger.info("pay order close, " + record.toString() + ", response: " + response); | |||||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||||
| String return_code = returnMap.get("return_code"); | |||||
| String result_code = returnMap.get("result_code"); | |||||
| if ("SUCCESS".equalsIgnoreCase(return_code)) { | |||||
| if ("SUCCESS".equals(result_code)) { | |||||
| record.setPayOrderStatus(EnumPayStatus.PAY_STATUS_CANCEL.getCode()); | |||||
| record.setUpdateTime(new Date()); | |||||
| try { | |||||
| wxPayOrderMapper.updateById(record); | |||||
| } catch (Exception e) { | |||||
| logger.error("pay order 关单:{} 成功", record.getId()); | |||||
| } | |||||
| return new ResultData(Result.SUCCESS, "支付订单关闭成功", returnMap); | |||||
| } else { | |||||
| String errMsg = ""; | |||||
| JSONObject errObj = errorMapClose.getJSONObject(result_code); | |||||
| if (errObj != null) { | |||||
| errMsg = errObj.toJSONString(); | |||||
| } else { | |||||
| errMsg = returnMap.get("return_msg"); | |||||
| } | |||||
| record.setFailReason(errMsg); | |||||
| record.setUpdateTime(new Date()); | |||||
| try { | |||||
| wxPayOrderMapper.updateById(record); | |||||
| } catch (Exception e) { | |||||
| logger.error("pay order update error: " + record.toString()); | |||||
| throw new MallinkException(ErrorCode.DB_FAIL); | |||||
| } | |||||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), errMsg, returnMap); | |||||
| } | |||||
| } else { | |||||
| String errMsg = returnMap.get("return_msg"); | |||||
| record.setFailReason(errMsg); | |||||
| record.setUpdateTime(new Date()); | |||||
| try { | |||||
| wxPayOrderMapper.updateById(record); | |||||
| } catch (Exception e) { | |||||
| logger.error("pay order update error: " + record.toString()); | |||||
| throw new MallinkException(ErrorCode.DB_FAIL); | |||||
| } | |||||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), errMsg, returnMap); | |||||
| WxPayAccount payAccount = wxPayAccountMapper.selectById(appInfo.getPayId()); | |||||
| try { | |||||
| PayAdapterResult result = payServiceFactory.getPayAdapterService(record.getPayVendor()).payOrderClose(appInfo, record, payAccount); | |||||
| if (result.isSuccess()) { | |||||
| record.setPayOrderStatus(EnumPayStatus.PAY_STATUS_CANCEL.getCode()); | |||||
| }else { | |||||
| record.setFailReason(result.getMsg()); | |||||
| } | |||||
| record.setUpdateTime(new Date()); | |||||
| try { | |||||
| wxPayOrderMapper.updateById(record); | |||||
| } catch (Exception e) { | |||||
| logger.error("pay order update error: " + record.toString()); | |||||
| throw new MallinkException(ErrorCode.DB_FAIL); | |||||
| } | } | ||||
| } catch (RuntimeException e) { | |||||
| if (result.isSuccess()) { | |||||
| return new ResultData(Result.SUCCESS, "支付订单关闭成功", result.getData()); | |||||
| }else { | |||||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), result.getMsg(), result.getData()); | |||||
| } | |||||
| } catch (RuntimeException e) { | |||||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | ||||
| } | } | ||||
| } | } | ||||
| private String wechatPayOrderReverse(WxAppinfo appInfo, WxPayOrder record) { | |||||
| // get payAccount | |||||
| WxPayAccount payAccount = wxPayAccountMapper.selectById(appInfo.getPayId()); | |||||
| if (payAccount.getType() == EnumPayMode.MCH.getCode()) { | |||||
| // 普通商户号模式 | |||||
| WxPayOrderQ payOrderC = new WxPayOrderQ(); | |||||
| String noncestr = Utility.generate32UUID(); | |||||
| payOrderC.setAppid(appInfo.getAppId()); | |||||
| payOrderC.setMch_id(payAccount.getMchId()); | |||||
| payOrderC.setNonce_str(noncestr); | |||||
| payOrderC.setOut_trade_no(record.getPayOrderNo()); | |||||
| try { | |||||
| Map map = BeanUtils.toStringMap(payOrderC); | |||||
| payOrderC.setSign(WxPayment.createSign(map, payAccount.getApiKey())); | |||||
| map = BeanUtils.toStringMap(payOrderC); | |||||
| String response = WxPay.orderReverse(map, payAccount.getCertPath(), payAccount.getMchId()); | |||||
| logger.info("request:" + map.toString() + "\nresponse:" + response); | |||||
| return response; | |||||
| } catch (RuntimeException e) { | |||||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||||
| } catch (Exception e) { | |||||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||||
| } | |||||
| } else { | |||||
| // 服务商模式 | |||||
| WxPayOrderSQ payOrderSC = new WxPayOrderSQ(); | |||||
| String noncestr = Utility.generate32UUID(); | |||||
| payOrderSC.setAppid(appInfo.getParentAppId()); | |||||
| payOrderSC.setSub_appid(appInfo.getAppId()); | |||||
| payOrderSC.setMch_id(payAccount.getMchId()); | |||||
| payOrderSC.setSub_mch_id(payAccount.getSubMchId()); | |||||
| payOrderSC.setNonce_str(noncestr); | |||||
| payOrderSC.setOut_trade_no(record.getPayOrderNo()); | |||||
| payOrderSC.setSign_type("HMAC-SHA256"); | |||||
| try { | |||||
| Map map = BeanUtils.toStringMap(payOrderSC); | |||||
| payOrderSC.setSign(WxPayment.createSignHMAC(map, payAccount.getApiKey())); | |||||
| map = BeanUtils.toStringMap(payOrderSC); | |||||
| String response = WxPay.orderReverse(map, payAccount.getCertPath(), payAccount.getMchId()); | |||||
| logger.info("request:" + map.toString() + "\nresponse:" + response); | |||||
| return response; | |||||
| } catch (RuntimeException e) { | |||||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||||
| } catch (Exception e) { | |||||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||||
| } | |||||
| } | |||||
| } | |||||
| /** | /** | ||||
| * 撤销订单 - 刷卡支付 | * 撤销订单 - 刷卡支付 | ||||
| @@ -763,102 +628,77 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| @Override | @Override | ||||
| public ResultData payOrderReverse(WxPayOrder record) { | public ResultData payOrderReverse(WxPayOrder record) { | ||||
| WxAppinfo appInfo = wxAppinfoService.getCAppInfo(record); | |||||
| WxAppinfo appInfo = wxAppinfoService.getCAppInfo(record,EnumPayWay.getEnum(record.getPayVendor())); | |||||
| WxPayAccount payAccount = wxPayAccountMapper.selectById(appInfo.getPayId()); | |||||
| try { | try { | ||||
| String response = wechatPayOrderReverse(appInfo, record); | |||||
| logger.info("pay order reverse, " + record.toString() + ", response: " + response); | |||||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||||
| String return_code = returnMap.get("return_code"); | |||||
| String result_code = returnMap.get("result_code"); | |||||
| if ("SUCCESS".equalsIgnoreCase(return_code)) { | |||||
| if ("SUCCESS".equals(result_code)) { | |||||
| record.setPayOrderStatus(EnumPayStatus.PAY_STATUS_REVERSE.getCode()); | |||||
| record.setUpdateTime(new Date()); | |||||
| try { | |||||
| wxPayOrderMapper.updateById(record); | |||||
| } catch (Exception e) { | |||||
| logger.error("pay order update error: " + record.toString()); | |||||
| throw new MallinkException(ErrorCode.DB_FAIL); | |||||
| } | |||||
| // 预核销撤回 | |||||
| WxPayOrder verifyPayOrder = null; | |||||
| WxPayOrder verifyPayOrderQ = new WxPayOrder(); | |||||
| verifyPayOrderQ.setPayFrom(EnumOrderFrom.INSIDE.getCode()); | |||||
| verifyPayOrderQ.setOrderId(record.getOrderId()); | |||||
| verifyPayOrderQ.setCUserId(record.getCUserId()); | |||||
| verifyPayOrderQ.setPayOrderStatus(EnumPayStatus.PAY_STATUS_WAIT.getCode()); | |||||
| try { | |||||
| verifyPayOrder = wxPayOrderMapper.selectOne(new QueryWrapper<>(verifyPayOrderQ)); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| if (verifyPayOrder != null) { | |||||
| verifyPayOrderQ = new WxPayOrder(); | |||||
| verifyPayOrderQ.setId(verifyPayOrder.getId()); | |||||
| verifyPayOrderQ.setPayOrderStatus(EnumPayStatus.PAY_STATUS_REVERSE.getCode()); | |||||
| verifyPayOrderQ.setUpdateTime(new Date()); | |||||
| try { | |||||
| wxPayOrderMapper.updateById(verifyPayOrderQ); | |||||
| } catch (Exception e) { | |||||
| logger.error("pay order update error: " + record.toString()); | |||||
| throw new MallinkException(ErrorCode.DB_FAIL); | |||||
| } | |||||
| PosCouponOrderVerify posCouponOrderVerifyQ = new PosCouponOrderVerify(); | |||||
| posCouponOrderVerifyQ.setCouponOrderId(verifyPayOrder.getPosPayOrderId()); | |||||
| posCouponOrderVerifyQ.setPosOrderId(record.getOrderId()); | |||||
| try { | |||||
| posCouponOrderVerifyMapper.delete(new UpdateWrapper<>(posCouponOrderVerifyQ)); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| WxCouponOrder updateCouponOrder = new WxCouponOrder(); | |||||
| updateCouponOrder.setId(verifyPayOrder.getPosPayOrderId()); | |||||
| updateCouponOrder.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USE_WAIT.getCode()); | |||||
| updateCouponOrder.setUpdateDate(new Date()); | |||||
| try { | |||||
| wxCouponOrderService.saveOrUpdate(updateCouponOrder); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| } | |||||
| // 预核销撤回-end | |||||
| WxOrder order = new WxOrder(); | |||||
| order.setId(record.getOrderId()); | |||||
| order.setType(EnumOrderType.MICROPAY.getCode()); | |||||
| order.setOrderStatus(EnumOrderStatus.ORDER_STATUS_OVERTIME_CANCEL.getCode()); | |||||
| order.setUpdateDate(new Date()); | |||||
| try { | |||||
| wxOrderMapper.updateById(order); | |||||
| } catch (Exception e) { | |||||
| logger.error("order update error: " + record.toString()); | |||||
| throw new MallinkException(ErrorCode.DB_FAIL); | |||||
| } | |||||
| return new ResultData(Result.SUCCESS, "订单撤销成功", returnMap); | |||||
| } else { | |||||
| String errMsg = ""; | |||||
| JSONObject errObj = errorMapClose.getJSONObject(result_code); | |||||
| if (errObj != null) { | |||||
| errMsg = errObj.toJSONString(); | |||||
| } else { | |||||
| errMsg = returnMap.get("return_msg"); | |||||
| } | |||||
| record.setFailReason(errMsg); | |||||
| record.setUpdateTime(new Date()); | |||||
| try { | |||||
| wxPayOrderMapper.updateById(record); | |||||
| } catch (Exception e) { | |||||
| logger.error("pay order update error: " + record.toString()); | |||||
| throw new MallinkException(ErrorCode.DB_FAIL); | |||||
| } | |||||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), errMsg, returnMap); | |||||
| } | |||||
| } else { | |||||
| String errMsg = returnMap.get("return_msg"); | |||||
| record.setFailReason(errMsg); | |||||
| PayAdapterResult result = payServiceFactory.getPayAdapterService(record.getPayVendor()).payOrderReverse(appInfo, record, payAccount); | |||||
| if (result.isSuccess()) { | |||||
| record.setPayOrderStatus(EnumPayStatus.PAY_STATUS_REVERSE.getCode()); | |||||
| record.setUpdateTime(new Date()); | |||||
| try { | |||||
| wxPayOrderMapper.updateById(record); | |||||
| } catch (Exception e) { | |||||
| logger.error("pay order update error: " + record.toString()); | |||||
| throw new MallinkException(ErrorCode.DB_FAIL); | |||||
| } | |||||
| // 预核销撤回 | |||||
| WxPayOrder verifyPayOrder = null; | |||||
| WxPayOrder verifyPayOrderQ = new WxPayOrder(); | |||||
| verifyPayOrderQ.setPayFrom(EnumOrderFrom.INSIDE.getCode()); | |||||
| verifyPayOrderQ.setOrderId(record.getOrderId()); | |||||
| verifyPayOrderQ.setCUserId(record.getCUserId()); | |||||
| verifyPayOrderQ.setPayOrderStatus(EnumPayStatus.PAY_STATUS_WAIT.getCode()); | |||||
| try { | |||||
| verifyPayOrder = wxPayOrderMapper.selectOne(new QueryWrapper<>(verifyPayOrderQ)); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| if (verifyPayOrder != null) { | |||||
| verifyPayOrderQ = new WxPayOrder(); | |||||
| verifyPayOrderQ.setId(verifyPayOrder.getId()); | |||||
| verifyPayOrderQ.setPayOrderStatus(EnumPayStatus.PAY_STATUS_REVERSE.getCode()); | |||||
| verifyPayOrderQ.setUpdateTime(new Date()); | |||||
| try { | |||||
| wxPayOrderMapper.updateById(verifyPayOrderQ); | |||||
| } catch (Exception e) { | |||||
| logger.error("pay order update error: " + record.toString()); | |||||
| throw new MallinkException(ErrorCode.DB_FAIL); | |||||
| } | |||||
| PosCouponOrderVerify posCouponOrderVerifyQ = new PosCouponOrderVerify(); | |||||
| posCouponOrderVerifyQ.setCouponOrderId(verifyPayOrder.getPosPayOrderId()); | |||||
| posCouponOrderVerifyQ.setPosOrderId(record.getOrderId()); | |||||
| try { | |||||
| posCouponOrderVerifyMapper.delete(new UpdateWrapper<>(posCouponOrderVerifyQ)); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| WxCouponOrder updateCouponOrder = new WxCouponOrder(); | |||||
| updateCouponOrder.setId(verifyPayOrder.getPosPayOrderId()); | |||||
| updateCouponOrder.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USE_WAIT.getCode()); | |||||
| updateCouponOrder.setUpdateDate(new Date()); | |||||
| try { | |||||
| wxCouponOrderService.saveOrUpdate(updateCouponOrder); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| } | |||||
| // 预核销撤回-end | |||||
| WxOrder order = new WxOrder(); | |||||
| order.setId(record.getOrderId()); | |||||
| order.setType(EnumOrderType.MICROPAY.getCode()); | |||||
| order.setOrderStatus(EnumOrderStatus.ORDER_STATUS_OVERTIME_CANCEL.getCode()); | |||||
| order.setUpdateDate(new Date()); | |||||
| try { | |||||
| wxOrderMapper.updateById(order); | |||||
| } catch (Exception e) { | |||||
| logger.error("order update error: " + record.toString()); | |||||
| throw new MallinkException(ErrorCode.DB_FAIL); | |||||
| } | |||||
| return new ResultData(Result.SUCCESS, result.getMsg(), result.getData()); | |||||
| }else { | |||||
| record.setFailReason(result.getMsg()); | |||||
| record.setUpdateTime(new Date()); | record.setUpdateTime(new Date()); | ||||
| try { | try { | ||||
| wxPayOrderMapper.updateById(record); | wxPayOrderMapper.updateById(record); | ||||
| @@ -866,8 +706,8 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| logger.error("pay order update error: " + record.toString()); | logger.error("pay order update error: " + record.toString()); | ||||
| throw new MallinkException(ErrorCode.DB_FAIL); | throw new MallinkException(ErrorCode.DB_FAIL); | ||||
| } | } | ||||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), errMsg, returnMap); | |||||
| } | |||||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), result.getMsg(), result.getData()); | |||||
| } | |||||
| } catch (RuntimeException e) { | } catch (RuntimeException e) { | ||||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | ||||
| @@ -1120,7 +960,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND); | throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND); | ||||
| } | } | ||||
| WxAppinfo appinfo = wxAppinfoService.getCAppInfo(order); | |||||
| WxAppinfo appinfo = wxAppinfoService.getCAppInfo(order,payWay); | |||||
| if (record.getPayAmount().equals(order.getTotalPayment())) { | if (record.getPayAmount().equals(order.getTotalPayment())) { | ||||
| doCouponPayOrder(user, record, order,payWay); | doCouponPayOrder(user, record, order,payWay); | ||||
| @@ -1235,7 +1075,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| // 有价券 | // 有价券 | ||||
| if (EnumPayStatus.PAY_STATUS_FAIL.getCode() == status) { | if (EnumPayStatus.PAY_STATUS_FAIL.getCode() == status) { | ||||
| // 1. get appinfo | // 1. get appinfo | ||||
| WxAppinfo appInfo = wxAppinfoService.getCAppInfo(order); | |||||
| WxAppinfo appInfo = wxAppinfoService.getCAppInfo(order,EnumPayWay.getEnum(record.getPayVendor())); | |||||
| // 前端支付取消, | // 前端支付取消, | ||||
| // 回调未返回,主动检查支付订单状态 | // 回调未返回,主动检查支付订单状态 | ||||
| try { | try { | ||||
| @@ -10,6 +10,7 @@ import com.iformall.domain.po.WxCoupon; | |||||
| import com.iformall.domain.po.WxCouponChannel; | import com.iformall.domain.po.WxCouponChannel; | ||||
| import com.iformall.domain.po.WxTopic; | import com.iformall.domain.po.WxTopic; | ||||
| import com.iformall.enums.EnumCouponChannelType; | import com.iformall.enums.EnumCouponChannelType; | ||||
| import com.iformall.enums.EnumPayWay; | |||||
| import com.iformall.enums.EnumWxTopicStatus; | import com.iformall.enums.EnumWxTopicStatus; | ||||
| import com.iformall.mapper.WxCouponChannelMapper; | import com.iformall.mapper.WxCouponChannelMapper; | ||||
| import com.iformall.mapper.WxCouponMapper; | import com.iformall.mapper.WxCouponMapper; | ||||
| @@ -141,7 +142,9 @@ public class WxTopicServiceImpl implements WxTopicService { | |||||
| couponChannel.setId(wxCouponChannel.getId()); | couponChannel.setId(wxCouponChannel.getId()); | ||||
| couponChannel.setType(wxCouponChannel.getType()); | couponChannel.setType(wxCouponChannel.getType()); | ||||
| String param = couponChannel.getWeappScene(); | String param = couponChannel.getWeappScene(); | ||||
| ResultData resultDataQ = qrCodeService.uploadQrcode(wxCoupon,1,pageUrl,param,0,"","","券"); | |||||
| //这里暂时只有微信二维码,有其他的码需要加字段 | |||||
| ResultData resultDataQ = qrCodeService.uploadQrcode(wxCoupon,1,pageUrl,param,0,"","","券",EnumPayWay.PAY_WAY_WECHAT); | |||||
| Map<String,String> map = (Map)resultDataQ.data; | Map<String,String> map = (Map)resultDataQ.data; | ||||
| if(map!=null && map.get("url") !=null) { | if(map!=null && map.get("url") !=null) { | ||||
| String url = map.get("url"); | String url = map.get("url"); | ||||
| @@ -1,6 +1,9 @@ | |||||
| package com.iformall.service.pay.service.pay; | package com.iformall.service.pay.service.pay; | ||||
| import java.io.File; | |||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.Map; | |||||
| import com.iformall.domain.po.WxAppinfo; | import com.iformall.domain.po.WxAppinfo; | ||||
| import com.iformall.domain.po.WxOrder; | import com.iformall.domain.po.WxOrder; | ||||
| import com.iformall.domain.po.WxPayAccount; | import com.iformall.domain.po.WxPayAccount; | ||||
| @@ -56,4 +59,31 @@ public interface PayAdapterService { | |||||
| * @throws Exception | * @throws Exception | ||||
| */ | */ | ||||
| public int queryPayStatusCode(WxPayOrder oldRecord,WxOrder order,WxAppinfo appInfo,WxPayAccount payAccount) throws Exception; | public int queryPayStatusCode(WxPayOrder oldRecord,WxOrder order,WxAppinfo appInfo,WxPayAccount payAccount) throws Exception; | ||||
| /** | |||||
| * API关闭订单 | |||||
| * @param appInfo | |||||
| * @param record | |||||
| * @param payAccount | |||||
| * @return | |||||
| * @throws Exception | |||||
| */ | |||||
| public PayAdapterResult payOrderClose(WxAppinfo appInfo, WxPayOrder record,WxPayAccount payAccount) throws Exception; | |||||
| /** | |||||
| * API 订单撤回 | |||||
| * @param appInfo | |||||
| * @param record | |||||
| * @param payAccount | |||||
| * @return | |||||
| * @throws Exception | |||||
| */ | |||||
| public PayAdapterResult payOrderReverse(WxAppinfo appInfo, WxPayOrder record,WxPayAccount payAccount) throws Exception; | |||||
| /** | |||||
| * 获取二维码 | |||||
| * @param param | |||||
| * @return | |||||
| */ | |||||
| public File getQrcode(WxAppinfo appinfo,String pageUrl,int type,String sceneParam) throws Exception; | |||||
| } | } | ||||
| @@ -1,15 +1,53 @@ | |||||
| package com.iformall.service.pay.service.pay.wx; | package com.iformall.service.pay.service.pay.wx; | ||||
| import java.io.File; | |||||
| import java.util.Date; | |||||
| import java.util.Map; | import java.util.Map; | ||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import com.alibaba.fastjson.JSON; | |||||
| import com.alibaba.fastjson.JSONObject; | |||||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||||
| import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.PosCouponOrderVerify; | |||||
| import com.iformall.domain.po.WxAppinfo; | import com.iformall.domain.po.WxAppinfo; | ||||
| import com.iformall.domain.po.WxCouponOrder; | |||||
| import com.iformall.domain.po.WxOrder; | import com.iformall.domain.po.WxOrder; | ||||
| import com.iformall.domain.po.WxPayAccount; | import com.iformall.domain.po.WxPayAccount; | ||||
| import com.iformall.domain.po.WxPayOrder; | import com.iformall.domain.po.WxPayOrder; | ||||
| import com.iformall.enums.EnumCouponOrderStatus; | |||||
| import com.iformall.enums.EnumOrderFrom; | |||||
| import com.iformall.enums.EnumOrderStatus; | |||||
| import com.iformall.enums.EnumOrderType; | |||||
| import com.iformall.enums.EnumPayMode; | |||||
| import com.iformall.enums.EnumPayStatus; | |||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.pay.WxPay; | |||||
| import com.iformall.pay.WxPayOrderQ; | |||||
| import com.iformall.pay.WxPayOrderSQ; | |||||
| import com.iformall.pay.WxPayment; | |||||
| import com.iformall.service.QrCodeService; | |||||
| import com.iformall.service.helper.WxPayOrderServiceHelper; | import com.iformall.service.helper.WxPayOrderServiceHelper; | ||||
| import com.iformall.service.pay.service.pay.PayAdapterService; | import com.iformall.service.pay.service.pay.PayAdapterService; | ||||
| import com.iformall.service.pay.service.pay.entity.PayAdapterResult; | |||||
| import com.iformall.service.pay.service.pay.entity.PayQueryAdapterResult; | import com.iformall.service.pay.service.pay.entity.PayQueryAdapterResult; | ||||
| import com.iformall.utils.BeanUtils; | |||||
| import com.iformall.utils.MaUtil; | |||||
| import com.iformall.utils.QRCodeUtils; | |||||
| import com.iformall.utils.Utility; | |||||
| import cn.binarywang.wx.miniapp.api.WxMaService; | |||||
| import cn.binarywang.wx.miniapp.bean.WxMaCodeLineColor; | |||||
| import lombok.extern.slf4j.Slf4j; | |||||
| import me.chanjar.weixin.common.error.WxErrorException; | |||||
| import me.chanjar.weixin.open.api.WxOpenService; | |||||
| @Slf4j | |||||
| public class BaseWxPayAdapterService { | public class BaseWxPayAdapterService { | ||||
| protected PayQueryAdapterResult queryPayStatus(WxPayOrder oldRecord, WxOrder order, WxAppinfo appInfo, WxPayAccount payAccount) | protected PayQueryAdapterResult queryPayStatus(WxPayOrder oldRecord, WxOrder order, WxAppinfo appInfo, WxPayAccount payAccount) | ||||
| @@ -29,4 +67,196 @@ public class BaseWxPayAdapterService { | |||||
| throws Exception { | throws Exception { | ||||
| return WxPayOrderServiceHelper.wxOrderPayStatus(oldRecord, order, appInfo, payAccount); | return WxPayOrderServiceHelper.wxOrderPayStatus(oldRecord, order, appInfo, payAccount); | ||||
| } | } | ||||
| JSONObject errorMapClose = JSON.parseObject("{" + | |||||
| "\"ORDERPAID\":{\"detail\":\"订单已支付\",\"reason\":\"订单已支付,不能发起关单\",\"resolution\":\"订单已支付,不能发起关单,请当作已支付的正常交易\"}," + | |||||
| "\"SYSTEMERROR\":{\"detail\":\"系统错误\",\"reason\":\"系统错误\",\"resolution\":\"系统异常,请重新调用该API\"}," + | |||||
| "\"ORDERCLOSED\":{\"detail\":\"订单已关闭\",\"reason\":\"订单已关闭,无法重复关闭\",\"resolution\":\"订单已关闭,无需继续调用\"}," + | |||||
| "\"SIGNERROR\":{\"detail\":\"签名错误\",\"reason\":\"参数签名结果不正确\",\"resolution\":\"请检查签名参数和方法是否都符合签名算法要求\"}," + | |||||
| "\"REQUIRE_POST_METHOD\":{\"detail\":\"请使用post方法\",\"reason\":\"未使用post传递参数\",\"resolution\":\"请检查请求参数是否通过post方法提交\"}," + | |||||
| "\"XML_FORMAT_ERROR\":{\"detail\":\"XML格式错误\t\",\"reason\":\"XML格式错误\",\"reason\":\"请检查XML参数格式是否正确\"}}"); | |||||
| protected PayAdapterResult closeOrder(WxAppinfo appInfo, WxPayOrder record,WxPayAccount payAccount) { | |||||
| String response = closeOrderWx(appInfo, record,payAccount); | |||||
| log.info("pay order close, " + record.toString() + ", response: " + response); | |||||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||||
| String return_code = returnMap.get("return_code"); | |||||
| String result_code = returnMap.get("result_code"); | |||||
| if ("SUCCESS".equalsIgnoreCase(return_code)) { | |||||
| if ("SUCCESS".equals(result_code)) { | |||||
| return new PayAdapterResult(true, "success", returnMap, null); | |||||
| } else { | |||||
| String errMsg = ""; | |||||
| JSONObject errObj = errorMapClose.getJSONObject(result_code); | |||||
| if (errObj != null) { | |||||
| errMsg = errObj.toJSONString(); | |||||
| } else { | |||||
| errMsg = returnMap.get("return_msg"); | |||||
| } | |||||
| return new PayAdapterResult(false, errMsg, returnMap, null); | |||||
| } | |||||
| } else { | |||||
| String errMsg = returnMap.get("return_msg"); | |||||
| return new PayAdapterResult(false, errMsg, returnMap, null); | |||||
| } | |||||
| } | |||||
| private String closeOrderWx(WxAppinfo appInfo, WxPayOrder record,WxPayAccount payAccount) { | |||||
| // get payAccount | |||||
| if (payAccount.getType() == EnumPayMode.MCH.getCode()) { | |||||
| // 普通商户号模式 | |||||
| WxPayOrderQ payOrderC = new WxPayOrderQ(); | |||||
| String noncestr = Utility.generate32UUID(); | |||||
| payOrderC.setAppid(appInfo.getAppId()); | |||||
| payOrderC.setMch_id(payAccount.getMchId()); | |||||
| payOrderC.setNonce_str(noncestr); | |||||
| payOrderC.setOut_trade_no(record.getPayOrderNo()); | |||||
| try { | |||||
| Map map = BeanUtils.toStringMap(payOrderC); | |||||
| payOrderC.setSign(WxPayment.createSign(map, payAccount.getApiKey())); | |||||
| map = BeanUtils.toStringMap(payOrderC); | |||||
| String response = WxPay.closeOrder(map); | |||||
| log.info("request:" + map.toString() + "\nresponse:" + response); | |||||
| return response; | |||||
| } catch (RuntimeException e) { | |||||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||||
| } catch (Exception e) { | |||||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||||
| } | |||||
| } else { | |||||
| // 服务商模式 | |||||
| WxPayOrderSQ payOrderSC = new WxPayOrderSQ(); | |||||
| String noncestr = Utility.generate32UUID(); | |||||
| payOrderSC.setAppid(appInfo.getParentAppId()); | |||||
| payOrderSC.setSub_appid(appInfo.getAppId()); | |||||
| payOrderSC.setMch_id(payAccount.getMchId()); | |||||
| payOrderSC.setSub_mch_id(payAccount.getSubMchId()); | |||||
| payOrderSC.setNonce_str(noncestr); | |||||
| payOrderSC.setOut_trade_no(record.getPayOrderNo()); | |||||
| payOrderSC.setSign_type("HMAC-SHA256"); | |||||
| try { | |||||
| Map map = BeanUtils.toStringMap(payOrderSC); | |||||
| payOrderSC.setSign(WxPayment.createSignHMAC(map, payAccount.getApiKey())); | |||||
| map = BeanUtils.toStringMap(payOrderSC); | |||||
| String response = WxPay.closeOrder(map); | |||||
| log.info("request:" + map.toString() + "\nresponse:" + response); | |||||
| return response; | |||||
| } catch (RuntimeException e) { | |||||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||||
| } catch (Exception e) { | |||||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||||
| } | |||||
| } | |||||
| } | |||||
| protected PayAdapterResult payOrderReverse(WxAppinfo appInfo, WxPayOrder record,WxPayAccount payAccount) throws Exception { | |||||
| String response = payOrderReverseWx(appInfo, record,payAccount); | |||||
| log.info("pay order reverse, " + record.toString() + ", response: " + response); | |||||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||||
| String return_code = returnMap.get("return_code"); | |||||
| String result_code = returnMap.get("result_code"); | |||||
| if ("SUCCESS".equalsIgnoreCase(return_code)) { | |||||
| if ("SUCCESS".equals(result_code)) { | |||||
| return new PayAdapterResult(true, "订单撤销成功", returnMap, null); | |||||
| } else { | |||||
| String errMsg = ""; | |||||
| JSONObject errObj = errorMapClose.getJSONObject(result_code); | |||||
| if (errObj != null) { | |||||
| errMsg = errObj.toJSONString(); | |||||
| } else { | |||||
| errMsg = returnMap.get("return_msg"); | |||||
| } | |||||
| return new PayAdapterResult(false, errMsg, returnMap, null); | |||||
| } | |||||
| } else { | |||||
| String errMsg = returnMap.get("return_msg"); | |||||
| return new PayAdapterResult(false, errMsg, returnMap, null); | |||||
| } | |||||
| } | |||||
| private String payOrderReverseWx(WxAppinfo appInfo, WxPayOrder record,WxPayAccount payAccount) { | |||||
| // get payAccount | |||||
| if (payAccount.getType() == EnumPayMode.MCH.getCode()) { | |||||
| // 普通商户号模式 | |||||
| WxPayOrderQ payOrderC = new WxPayOrderQ(); | |||||
| String noncestr = Utility.generate32UUID(); | |||||
| payOrderC.setAppid(appInfo.getAppId()); | |||||
| payOrderC.setMch_id(payAccount.getMchId()); | |||||
| payOrderC.setNonce_str(noncestr); | |||||
| payOrderC.setOut_trade_no(record.getPayOrderNo()); | |||||
| try { | |||||
| Map map = BeanUtils.toStringMap(payOrderC); | |||||
| payOrderC.setSign(WxPayment.createSign(map, payAccount.getApiKey())); | |||||
| map = BeanUtils.toStringMap(payOrderC); | |||||
| String response = WxPay.orderReverse(map, payAccount.getCertPath(), payAccount.getMchId()); | |||||
| log.info("request:" + map.toString() + "\nresponse:" + response); | |||||
| return response; | |||||
| } catch (RuntimeException e) { | |||||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||||
| } catch (Exception e) { | |||||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||||
| } | |||||
| } else { | |||||
| // 服务商模式 | |||||
| WxPayOrderSQ payOrderSC = new WxPayOrderSQ(); | |||||
| String noncestr = Utility.generate32UUID(); | |||||
| payOrderSC.setAppid(appInfo.getParentAppId()); | |||||
| payOrderSC.setSub_appid(appInfo.getAppId()); | |||||
| payOrderSC.setMch_id(payAccount.getMchId()); | |||||
| payOrderSC.setSub_mch_id(payAccount.getSubMchId()); | |||||
| payOrderSC.setNonce_str(noncestr); | |||||
| payOrderSC.setOut_trade_no(record.getPayOrderNo()); | |||||
| payOrderSC.setSign_type("HMAC-SHA256"); | |||||
| try { | |||||
| Map map = BeanUtils.toStringMap(payOrderSC); | |||||
| payOrderSC.setSign(WxPayment.createSignHMAC(map, payAccount.getApiKey())); | |||||
| map = BeanUtils.toStringMap(payOrderSC); | |||||
| String response = WxPay.orderReverse(map, payAccount.getCertPath(), payAccount.getMchId()); | |||||
| log.info("request:" + map.toString() + "\nresponse:" + response); | |||||
| return response; | |||||
| } catch (RuntimeException e) { | |||||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||||
| } catch (Exception e) { | |||||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||||
| } | |||||
| } | |||||
| } | |||||
| @Autowired | |||||
| WxOpenService openService; | |||||
| protected File getQrCode(WxAppinfo appinfo,String pageUrl,int type,String sceneParam) throws WxErrorException { | |||||
| boolean isFmOpen = false; | |||||
| WxMaService wxMaService; | |||||
| if(isFmOpen) { | |||||
| wxMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appinfo.getAppId()); | |||||
| } else { | |||||
| wxMaService = MaUtil.getWeappService(appinfo); | |||||
| } | |||||
| boolean autoColor = false; | |||||
| boolean isHyaline = true; | |||||
| WxMaCodeLineColor color = new WxMaCodeLineColor("0", "0", "0"); | |||||
| String pathStr = ""; | |||||
| if (StringUtils.isNotBlank(sceneParam)) { | |||||
| pathStr = pageUrl + "?scene="+sceneParam; | |||||
| } else { | |||||
| pathStr = pageUrl; | |||||
| } | |||||
| if(type == 0) { | |||||
| final File codeFile = wxMaService.getQrcodeService().createQrcode(pathStr, QRCodeUtils.QR_WIDTH); | |||||
| return codeFile; | |||||
| }else { | |||||
| final File codeFile = wxMaService.getQrcodeService().createWxaCodeUnlimit(sceneParam, pageUrl, QRCodeUtils.QR_WIDTH, autoColor, color, isHyaline); | |||||
| return codeFile; | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -1,6 +1,8 @@ | |||||
| package com.iformall.service.pay.service.pay.wx.h5; | package com.iformall.service.pay.service.pay.wx.h5; | ||||
| import java.io.File; | |||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.Map; | |||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| @@ -41,5 +43,25 @@ public class WxH5PayService extends BaseWxPayAdapterService implements CDriving | |||||
| throws Exception { | throws Exception { | ||||
| return super.queryPayStatusCode(oldRecord, order, appInfo, payAccount); | return super.queryPayStatusCode(oldRecord, order, appInfo, payAccount); | ||||
| } | } | ||||
| @Override | |||||
| public PayAdapterResult payOrderClose(WxAppinfo appInfo, WxPayOrder record, WxPayAccount payAccount) | |||||
| throws Exception { | |||||
| // TODO Auto-generated method stub | |||||
| return null; | |||||
| } | |||||
| @Override | |||||
| public PayAdapterResult payOrderReverse(WxAppinfo appInfo, WxPayOrder record, WxPayAccount payAccount) | |||||
| throws Exception { | |||||
| // TODO Auto-generated method stub | |||||
| return null; | |||||
| } | |||||
| @Override | |||||
| public File getQrcode(WxAppinfo appinfo,String pageUrl,int type,String sceneParam) throws Exception{ | |||||
| // TODO Auto-generated method stub | |||||
| return null; | |||||
| } | |||||
| } | } | ||||
| @@ -1,5 +1,6 @@ | |||||
| package com.iformall.service.pay.service.pay.wx.miniApp.appPay; | package com.iformall.service.pay.service.pay.wx.miniApp.appPay; | ||||
| import java.io.File; | |||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.Map; | import java.util.Map; | ||||
| @@ -251,4 +252,20 @@ public class WxMiniAppPayAdapterService extends BaseWxPayAdapterService implemen | |||||
| return super.queryPayStatusCode(oldRecord, order, appInfo, payAccount); | return super.queryPayStatusCode(oldRecord, order, appInfo, payAccount); | ||||
| } | } | ||||
| @Override | |||||
| public PayAdapterResult payOrderClose(WxAppinfo appInfo, WxPayOrder record,WxPayAccount payAccount) throws Exception { | |||||
| return super.closeOrder(appInfo, record, payAccount); | |||||
| } | |||||
| @Override | |||||
| public PayAdapterResult payOrderReverse(WxAppinfo appInfo, WxPayOrder record, WxPayAccount payAccount) | |||||
| throws Exception { | |||||
| return super.payOrderReverse(appInfo, record, payAccount); | |||||
| } | |||||
| @Override | |||||
| public File getQrcode(WxAppinfo appinfo,String pageUrl,int type,String sceneParam) throws Exception{ | |||||
| return super.getQrCode(appinfo, pageUrl, type, sceneParam); | |||||
| } | |||||
| } | } | ||||
| @@ -1,5 +1,6 @@ | |||||
| package com.iformall.service.pay.service.pay.wx.miniApp.maPay; | package com.iformall.service.pay.service.pay.wx.miniApp.maPay; | ||||
| import java.io.File; | |||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.Map; | import java.util.Map; | ||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| @@ -31,6 +32,7 @@ import com.iformall.service.pay.service.pay.wx.BaseWxPayAdapterService; | |||||
| import com.iformall.utils.BeanUtils; | import com.iformall.utils.BeanUtils; | ||||
| import com.iformall.utils.Utility; | import com.iformall.utils.Utility; | ||||
| import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
| import me.chanjar.weixin.common.error.WxErrorException; | |||||
| @Slf4j | @Slf4j | ||||
| @@ -246,5 +248,21 @@ public class WxMiniMaPayAdapterService extends BaseWxPayAdapterService implement | |||||
| return super.queryPayStatusCode(oldRecord, order, appInfo, payAccount); | return super.queryPayStatusCode(oldRecord, order, appInfo, payAccount); | ||||
| } | } | ||||
| @Override | |||||
| public PayAdapterResult payOrderClose(WxAppinfo appInfo, WxPayOrder record,WxPayAccount payAccount) throws Exception { | |||||
| return super.closeOrder(appInfo, record, payAccount); | |||||
| } | |||||
| @Override | |||||
| public PayAdapterResult payOrderReverse(WxAppinfo appInfo, WxPayOrder record, WxPayAccount payAccount) | |||||
| throws Exception { | |||||
| return super.payOrderReverse(appInfo, record, payAccount); | |||||
| } | |||||
| @Override | |||||
| public File getQrcode(WxAppinfo appinfo,String pageUrl,int type,String sceneParam) throws Exception { | |||||
| return super.getQrCode(appinfo, pageUrl, type, sceneParam); | |||||
| } | |||||
| } | } | ||||
| @@ -9,6 +9,7 @@ import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | import com.iformall.controller.base.BaseController; | ||||
| import com.iformall.domain.po.WxAppinfo; | import com.iformall.domain.po.WxAppinfo; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.enums.EnumPayWay; | |||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.service.WxAppinfoService; | import com.iformall.service.WxAppinfoService; | ||||
| import com.iformall.service.wechat.FmOpenService; | import com.iformall.service.wechat.FmOpenService; | ||||
| @@ -139,7 +140,7 @@ public class WxAppinfoController extends BaseController { | |||||
| String name) { | String name) { | ||||
| // type 0 有限二维码, 1 无限制二维码 | // type 0 有限二维码, 1 无限制二维码 | ||||
| // withText 0 不带字 1. 带下面的字,2 带下面的两行字 | // withText 0 不带字 1. 带下面的字,2 带下面的两行字 | ||||
| WxAppinfo appinfo = wxAppinfoService.getCAppInfo(tenantEntity); | |||||
| WxAppinfo appinfo = wxAppinfoService.getCAppInfo(tenantEntity,EnumPayWay.PAY_WAY_WECHAT); | |||||
| boolean autoColor = false; | boolean autoColor = false; | ||||
| boolean isHyaline = true; | boolean isHyaline = true; | ||||
| WxMaCodeLineColor color = new WxMaCodeLineColor("0", "0", "0"); | WxMaCodeLineColor color = new WxMaCodeLineColor("0", "0", "0"); | ||||