| @@ -14,6 +14,11 @@ public class PayProperty { | |||
| */ | |||
| private boolean real; | |||
| /** | |||
| * 是否分账 | |||
| */ | |||
| private boolean share; | |||
| public boolean isReal() { | |||
| return real; | |||
| } | |||
| @@ -21,4 +26,12 @@ public class PayProperty { | |||
| public void setReal(boolean real) { | |||
| this.real = real; | |||
| } | |||
| public boolean isShare() { | |||
| return share; | |||
| } | |||
| public void setShare(boolean share) { | |||
| this.share = share; | |||
| } | |||
| } | |||
| @@ -1,13 +1,7 @@ | |||
| package com.simple.config; | |||
| import java.util.HashMap; | |||
| import java.util.LinkedHashMap; | |||
| import java.util.Map; | |||
| import javax.servlet.ServletRequest; | |||
| import javax.servlet.ServletResponse; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import com.simple.service.MallPermissionService; | |||
| import com.simple.shiro.MyShiroRealm; | |||
| import org.apache.shiro.authc.credential.HashedCredentialsMatcher; | |||
| import org.apache.shiro.mgt.SecurityManager; | |||
| import org.apache.shiro.spring.LifecycleBeanPostProcessor; | |||
| @@ -24,10 +18,11 @@ import org.springframework.beans.factory.annotation.Value; | |||
| import org.springframework.context.annotation.Bean; | |||
| import org.springframework.context.annotation.Configuration; | |||
| import com.simple.service.MallPermissionService; | |||
| import com.simple.shiro.MyShiroRealm; | |||
| import javax.servlet.Filter; | |||
| import javax.servlet.ServletRequest; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import java.util.LinkedHashMap; | |||
| import java.util.Map; | |||
| /** | |||
| @@ -123,11 +118,14 @@ public class ShiroConfig { | |||
| filterChainDefinitionMap.put("/webjars/**","anon"); | |||
| filterChainDefinitionMap.put("/wxMsgCallback/**","anon"); | |||
| filterChainDefinitionMap.put("/carCallback/**","anon"); | |||
| filterChainDefinitionMap.put("/wxMallApply/add","anon"); | |||
| filterChainDefinitionMap.put("/wxMallApply/sendvalidationcode","anon"); | |||
| // filterChainDefinitionMap.put("/role/**", "corsFilter,token"); | |||
| filterChainDefinitionMap.put("/**", "corsFilter,token,authc"); | |||
| // filterChainDefinitionMap.put("/**", "anon"); | |||
| shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap); | |||
| return shiroFilterFactoryBean; | |||
| } | |||
| @@ -8,11 +8,9 @@ import com.simple.common.ResultData; | |||
| import com.simple.domain.po.*; | |||
| import com.simple.enums.EnumCarCmd; | |||
| import com.simple.enums.EnumCarVendor; | |||
| import com.simple.enums.EnumCouponSendType; | |||
| import com.simple.enums.EnumETCPCode; | |||
| import com.simple.service.WxCUserCarService; | |||
| import com.simple.service.WxCarCmdLogService; | |||
| import com.simple.service.WxMerchantService; | |||
| import com.simple.service.WxParkService; | |||
| import com.simple.service.*; | |||
| import com.simple.utils.ETCPUtil; | |||
| import com.simple.utils.TJDCarUtil; | |||
| import io.swagger.annotations.ApiOperation; | |||
| @@ -23,6 +21,7 @@ import org.springframework.web.bind.annotation.*; | |||
| import java.util.Date; | |||
| import java.util.HashMap; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| @RestController | |||
| @@ -47,6 +46,9 @@ public class WxCarCallBackController extends BaseController | |||
| @Autowired | |||
| WxCarCmdLogService wxCarCmdLogService; | |||
| @Autowired | |||
| WxCouponSendService wxCouponSendService; | |||
| /** | |||
| * ETCP 车辆入场通知 | |||
| * { | |||
| @@ -74,6 +76,7 @@ public class WxCarCallBackController extends BaseController | |||
| wxCarCmdLog.setUpdateDate(currentDate); | |||
| String etcpParkId = paramMap.get("parkId"); | |||
| String tenantId = "456"; | |||
| WxPark parkQ = new WxPark(); | |||
| parkQ.setVendorType(EnumCarVendor.CAR_ETCP.getCode()); | |||
| parkQ.setParkId(etcpParkId); | |||
| @@ -82,6 +85,7 @@ public class WxCarCallBackController extends BaseController | |||
| logger.error("etcpParkInCallback: ETCP车场未找到"+ etcpParkId); | |||
| //return new Result(ErrorCode.CAR_PARK_NOT_FOUND.getCode(), "ETCP车场未找到"+ etcpParkId); | |||
| } else { | |||
| tenantId = park.getTenantId(); | |||
| wxCarCmdLog.setTenantId(park.getTenantId()); | |||
| } | |||
| @@ -92,7 +96,22 @@ public class WxCarCallBackController extends BaseController | |||
| return new Result(ErrorCode.DB_FAIL.getCode(), "入库错误"+paramMap.toString()); | |||
| } | |||
| // TODO 发起 营销 -- 短信 | |||
| // 停车发券 | |||
| String carNumber = paramMap.get("plateNumber"); | |||
| if (!StringUtils.isBlank(carNumber)) { | |||
| // 根据车牌查找用户 | |||
| WxCUserCar userCarQ = new WxCUserCar(); | |||
| userCarQ.setTenantId(tenantId); | |||
| userCarQ.setCarNumber(carNumber); | |||
| userCarQ.setVendorType(EnumCarVendor.CAR_ETCP.getCode()); | |||
| // TODO 可能多用户关联同一张车牌 | |||
| List<WxCUserCar> userCarList = wxCUserCarService.getList(userCarQ); | |||
| for(WxCUserCar userCar: userCarList) { | |||
| wxCouponSendService.sendCouponToUser(tenantId, userCar.getCUserId(), EnumCouponSendType.CAR_STOP.getCode()); | |||
| } | |||
| } | |||
| return new Result(EnumETCPCode.SUCCESS.getCode(), EnumETCPCode.SUCCESS.getMessage()); | |||
| } | |||
| @@ -217,13 +217,13 @@ public class WxCarController extends BaseController | |||
| wxCoupon.setTenantId(user.getTenantId()); | |||
| wxCoupon.setMerchantId(coupon.getMerchantId()); | |||
| if(StringUtils.isNotEmpty(coupon.getSalePriceStr())){ | |||
| wxCoupon.setSalePrice((int)Double.parseDouble(coupon.getSalePriceStr())*100); | |||
| wxCoupon.setSalePrice((int)(Double.parseDouble(coupon.getSalePriceStr())*100)); | |||
| } | |||
| if(StringUtils.isNotEmpty(coupon.getUsePriceStr())){ | |||
| wxCoupon.setUsePrice((int)Double.parseDouble(coupon.getUsePriceStr())*100); | |||
| wxCoupon.setUsePrice((int)(Double.parseDouble(coupon.getUsePriceStr())*100)); | |||
| } | |||
| if(StringUtils.isNotEmpty(coupon.getPriceStr())){ | |||
| wxCoupon.setPrice((int)Double.parseDouble(coupon.getPriceStr())*100); | |||
| wxCoupon.setPrice((int)(Double.parseDouble(coupon.getPriceStr())*100)); | |||
| } | |||
| if(StringUtils.isNotBlank(coupon.getBusiness())) { | |||
| String[] arys = coupon.getBusiness().split(","); | |||
| @@ -74,7 +74,7 @@ public class WxCouponController extends BaseController | |||
| wxCouponChannel.setCouponIds(ids); | |||
| wxCouponChannel.setStatus(0); | |||
| //上架状态 | |||
| List<WxCouponChannel> list = wxCouponChannelService.listAsPage(wxCouponChannel,1,5).getList(); | |||
| List<WxCouponChannel> list = wxCouponChannelService.listAsPage(wxCouponChannel,1,10000).getList(); | |||
| if(!list.isEmpty()){ | |||
| Map<Long, List<WxCouponChannel>> groupBy = list.stream().collect(Collectors.groupingBy(WxCouponChannel::getCouponId)); | |||
| for (WxCoupon temp:wxCouponList) { | |||
| @@ -0,0 +1,75 @@ | |||
| package com.simple.controller; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.simple.common.Result; | |||
| import com.simple.common.ResultData; | |||
| import com.simple.domain.po.WxMallApply; | |||
| import com.simple.domain.po.WxMsgValidationcode; | |||
| import com.simple.service.WxMallApplyService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import org.apache.log4j.Logger; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| @RestController | |||
| @RequestMapping("wxMallApply") | |||
| public class WxMallApplyController extends BaseController | |||
| { | |||
| @Autowired | |||
| private WxMallApplyService wxMallApplyService; | |||
| private Logger logger = Logger.getLogger(WxMallApplyController.class); | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true), | |||
| @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)}) | |||
| public ResultData list(@ModelAttribute WxMallApply wxMallApply,Integer pageNum, Integer pageSize) { | |||
| if (null == wxMallApply) wxMallApply = new WxMallApply(); | |||
| final PageInfo<WxMallApply> page = wxMallApplyService.listAsPage(wxMallApply, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @PostMapping("add") | |||
| public ResultData add(@RequestBody WxMallApply wxMallApply) { | |||
| //Assert.notNull(wxMallApply.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| wxMallApplyService.saveOrUpdate(wxMallApply); | |||
| return new ResultData(); | |||
| } | |||
| @PostMapping("update") | |||
| public ResultData update(@RequestBody WxMallApply wxMallApply) { | |||
| wxMallApplyService.saveOrUpdate(wxMallApply); | |||
| return new ResultData(); | |||
| } | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name="id",value="id",dataType="String", paramType = "query",required=true) | |||
| public ResultData delete(String id) { | |||
| wxMallApplyService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name="id",value="id",dataType="String", paramType = "query",required=true) | |||
| public ResultData findById(String id) { | |||
| return new ResultData(Result.SUCCESS,"查询成功",wxMallApplyService.getById(id)); | |||
| } | |||
| @GetMapping("sendvalidationcode") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "phone", value = "手机号", dataType = "String", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "type", value = "场景", dataType = "Integer", paramType = "query", required = true)}) | |||
| public ResultData sendvalidationcode(String phone, Integer type) { | |||
| WxMsgValidationcode wxMsgValidationcode = new WxMsgValidationcode(); | |||
| wxMsgValidationcode.setTenantId("1"); | |||
| wxMsgValidationcode.setPhone(phone); | |||
| wxMsgValidationcode.setType(type); | |||
| return wxMallApplyService.sendvalidationcode(wxMsgValidationcode); | |||
| } | |||
| } | |||
| @@ -30,6 +30,7 @@ public class WxMerchantController extends BaseController { | |||
| public ResultData list(@ModelAttribute WxMerchant wxMerchant, Integer pageNum, Integer pageSize) { | |||
| if (null == wxMerchant) wxMerchant = new WxMerchant(); | |||
| wxMerchant.setTenantId(getTenantId()); | |||
| wxMerchant.setSortColumns(WxMerchant.Field.Id_DESC); | |||
| final PageInfo<WxMerchant> page = wxMerchantService.listAsPage(wxMerchant, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @@ -30,6 +30,7 @@ public class WxMsgCallbackController extends BaseController | |||
| @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)}) | |||
| public ResultData list(@ModelAttribute WxMsgCallback wxMsgCallback,Integer pageNum, Integer pageSize) { | |||
| if (null == wxMsgCallback) wxMsgCallback = new WxMsgCallback(); | |||
| wxMsgCallback.setTenantId(getTenantId()); | |||
| final PageInfo<WxMsgCallback> page = wxMsgCallbackService.listAsPage(wxMsgCallback, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @@ -39,6 +40,7 @@ public class WxMsgCallbackController extends BaseController | |||
| public ResultData add(@RequestBody WxMsgCallback wxMsgCallback) { | |||
| //Assert.notNull(wxMsgCallback.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| wxMsgCallback.setTenantId(getTenantId()); | |||
| wxMsgCallbackService.saveOrUpdate(wxMsgCallback); | |||
| return new ResultData(); | |||
| } | |||
| @@ -71,14 +73,15 @@ public class WxMsgCallbackController extends BaseController | |||
| //解析param数据插入数据库中 | |||
| String item = param.get("item"); | |||
| String sign = param.get("sign"); | |||
| wxMsgCallbackService.saveOrUpdate(bid,item,sign); | |||
| String tenantId=getTenantId(); | |||
| wxMsgCallbackService.saveOrUpdate(tenantId,bid,item,sign); | |||
| } | |||
| @RequestMapping(value = "/receivemodel/{bid}") | |||
| public void receivemodel(@PathVariable String bid, @RequestParam Map<String,String> param) { | |||
| //解析param数据插入数据库中 | |||
| wxMsgCallbackService.receivemodel(bid,param); | |||
| wxMsgCallbackService.receivemodel(getTenantId(),bid,param); | |||
| } | |||
| @@ -35,6 +35,7 @@ public class WxMsgController extends BaseController | |||
| @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)}) | |||
| public ResultData list(@ModelAttribute WxMsg wxMsg,Integer pageNum, Integer pageSize) { | |||
| if (null == wxMsg) wxMsg = new WxMsg(); | |||
| wxMsg.setTenantId(getTenantId()); | |||
| final PageInfo<WxMsg> page = wxMsgService.listAsPage(wxMsg, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @@ -28,6 +28,7 @@ public class WxMsgModelController extends BaseController | |||
| @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)}) | |||
| public ResultData list(@ModelAttribute WxMsgModel wxMsgModel,Integer pageNum, Integer pageSize) { | |||
| if (null == wxMsgModel) wxMsgModel = new WxMsgModel(); | |||
| wxMsgModel.setTenantId(getTenantId()); | |||
| final PageInfo<WxMsgModel> page = wxMsgModelService.listAsPage(wxMsgModel, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @@ -28,6 +28,7 @@ public class WxMsgSignatureController extends BaseController | |||
| @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)}) | |||
| public ResultData list(@ModelAttribute WxMsgSignature wxMsgSignature,Integer pageNum, Integer pageSize) { | |||
| if (null == wxMsgSignature) wxMsgSignature = new WxMsgSignature(); | |||
| wxMsgSignature.setTenantId(getTenantId()); | |||
| final PageInfo<WxMsgSignature> page = wxMsgSignatureService.listAsPage(wxMsgSignature, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @@ -37,6 +38,7 @@ public class WxMsgSignatureController extends BaseController | |||
| public ResultData add(@RequestBody WxMsgSignature wxMsgSignature) { | |||
| //Assert.notNull(wxMsgSignature.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| wxMsgSignature.setTenantId(getTenantId()); | |||
| wxMsgSignatureService.saveOrUpdate(wxMsgSignature); | |||
| return new ResultData(); | |||
| } | |||
| @@ -66,7 +68,7 @@ public class WxMsgSignatureController extends BaseController | |||
| @ApiOperation("获取所有数据") | |||
| @GetMapping("getsignaturelist") | |||
| public ResultData getmodellist() { | |||
| return wxMsgSignatureService.getsignaturelist(); | |||
| return wxMsgSignatureService.getsignaturelist(getTenantId()); | |||
| } | |||
| @@ -1,9 +1,9 @@ | |||
| package com.simple.controller; | |||
| import com.simple.service.WxAppinfoService; | |||
| import com.simple.service.WxProfitSharingOrderService; | |||
| import org.apache.log4j.Logger; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.util.Assert; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import com.github.pagehelper.PageInfo; | |||
| @@ -73,10 +73,15 @@ public class WxPayOrderController extends BaseController | |||
| @Autowired | |||
| private WxProfitSharingOrderService xProfitSharingOrderService; | |||
| @Autowired | |||
| private WxAppinfoService wxAppinfoService; | |||
| @ApiOperation("测试分账") | |||
| @GetMapping("/sharing") | |||
| public ResultData test() { | |||
| xProfitSharingOrderService.test(); | |||
| //xProfitSharingOrderService.test(); | |||
| wxPayOrderService.sendPaySuccess(); | |||
| return new ResultData(); | |||
| } | |||
| @@ -0,0 +1,85 @@ | |||
| package com.simple.controller; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.simple.common.ErrorCode; | |||
| import com.simple.common.Result; | |||
| import com.simple.common.ResultData; | |||
| import com.simple.domain.po.WxMerchant; | |||
| import com.simple.domain.po.WxProfitSharingReceiver; | |||
| import com.simple.service.WxMerchantService; | |||
| import com.simple.service.WxProfitSharingReceiverService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.apache.log4j.Logger; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.List; | |||
| @RestController | |||
| @RequestMapping("wxProfitSharingReceiver") | |||
| public class WxProfitSharingReceiverController extends BaseController { | |||
| @Autowired | |||
| private WxProfitSharingReceiverService wxProfitSharingReceiverService; | |||
| @Autowired | |||
| private WxMerchantService wxMerchantService; | |||
| private Logger logger = Logger.getLogger(WxProfitSharingReceiverController.class); | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| public ResultData list(@ModelAttribute WxProfitSharingReceiver receiver, Integer pageNum, Integer pageSize) { | |||
| if (null == receiver) receiver = new WxProfitSharingReceiver(); | |||
| final PageInfo<WxProfitSharingReceiver> page = wxProfitSharingReceiverService.listAsPage(receiver, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| public ResultData add(@RequestBody WxProfitSharingReceiver receiver) { | |||
| if (receiver == null) | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| if (receiver.getMerchantId() == null) | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| if (receiver.getReceiverType() == null) | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| if (receiver.getReceiverComments() == null) | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| if (receiver.getReceiverAccount() == null) | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| WxMerchant merchant = wxMerchantService.getById(receiver.getMerchantId()); | |||
| if (merchant == null) | |||
| return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND); | |||
| return wxProfitSharingReceiverService.addReceiver(merchant, receiver); | |||
| } | |||
| @ApiOperation("根据id删除接口") | |||
| @GetMapping("del") | |||
| public ResultData delete(@RequestBody WxProfitSharingReceiver receiver) { | |||
| if (receiver == null) | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| if (receiver.getMerchantId() == null) | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| if (receiver.getReceiverType() == null) | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| if (receiver.getReceiverAccount() == null) | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| WxMerchant merchant = wxMerchantService.getById(receiver.getMerchantId()); | |||
| if (merchant == null) | |||
| return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND); | |||
| return wxProfitSharingReceiverService.delReceiver(merchant, receiver); | |||
| } | |||
| } | |||
| @@ -23,8 +23,8 @@ public class WxShopController extends BaseController | |||
| private WxShopService wxShopService; | |||
| private Logger logger = Logger.getLogger(WxShopController.class); | |||
| @ApiOperation("分页列表接口") | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true), | |||
| @@ -32,6 +32,8 @@ public class WxShopController extends BaseController | |||
| public ResultData list(@ModelAttribute WxShop wxShop,Integer pageNum, Integer pageSize) { | |||
| if (null == wxShop) wxShop = new WxShop(); | |||
| wxShop.setTenantId(getTenantId()); | |||
| wxShop.setSortColumns(WxShop.Field.Id_DESC); | |||
| final PageInfo<Map<String,Object>> page = wxShopService.listMapAsPage(wxShop, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @@ -25,18 +25,12 @@ public class CouponExpiringSchedule { | |||
| private final Logger logger = Logger.getLogger(CouponExpiringSchedule.class); | |||
| @Autowired | |||
| private WxMallMapper wxMallMapper; | |||
| @Autowired | |||
| private WxCouponChannelMapper wxCouponChannelMapper; | |||
| @Autowired | |||
| private WxCouponMapper wxCouponMapper; | |||
| @Scheduled(cron = "0 30 0 * * ?") // 每天凌晨 | |||
| @Scheduled(cron = "0 5 0 * * ?") // 每天凌晨00:05 | |||
| //@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 | |||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||
| public void couponExpiringSchedule() { | |||
| @@ -45,11 +39,12 @@ public class CouponExpiringSchedule { | |||
| } | |||
| @Scheduled(cron = "0 5 0 * * ?") // 每天凌晨 | |||
| @Scheduled(cron = "0 5 0 * * ?") // 每天凌晨00:05 | |||
| //@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 | |||
| public void couponChannelExpiringSchedule() { | |||
| wxCouponChannelMapper.offExpiriedCouponChannelByEndTime(); | |||
| wxCouponChannelMapper.offExpiriedCouponChannelByValidDate(); | |||
| wxCouponChannelMapper.offExpiriedCouponChannelByCouponStatus(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,76 @@ | |||
| package com.simple.schedule; | |||
| import com.simple.common.ErrorCode; | |||
| import com.simple.common.ResultData; | |||
| import com.simple.config.PayProperty; | |||
| import com.simple.domain.po.*; | |||
| import com.simple.domain.vo.WxCouponOrderCVo; | |||
| import com.simple.enums.EnumAppType; | |||
| import com.simple.enums.EnumPayStatus; | |||
| import com.simple.enums.EnumPayWay; | |||
| import com.simple.enums.EnumRefundWay; | |||
| import com.simple.exception.MallinkException; | |||
| import com.simple.mapper.*; | |||
| import com.simple.service.WxAppinfoService; | |||
| import com.simple.service.WxPayOrderService; | |||
| import com.simple.service.WxRefundOrderService; | |||
| import org.apache.log4j.Logger; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.scheduling.annotation.Scheduled; | |||
| import org.springframework.stereotype.Component; | |||
| import org.springframework.transaction.annotation.Propagation; | |||
| import org.springframework.transaction.annotation.Transactional; | |||
| import java.util.List; | |||
| @Component | |||
| public class CouponOrderExpiringSchedule { | |||
| private final Logger logger = Logger.getLogger(CouponOrderExpiringSchedule.class); | |||
| @Autowired | |||
| private WxCouponOrderMapper wxCouponOrderMapper; | |||
| @Autowired | |||
| private PayProperty payProperty; | |||
| @Autowired | |||
| private WxRefundOrderService wxRefundOrderService; | |||
| @Autowired | |||
| private WxPayOrderService wxPayOrderService; | |||
| @Autowired | |||
| private WxAppinfoMapper wxAppinfoMapper; | |||
| @Scheduled(cron = "0 5 0 * * ?") // 每天凌晨00:05 | |||
| //@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 | |||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||
| public void couponOrderExpiringSchedule() { | |||
| wxCouponOrderMapper.offExpiredCouponOrderByValidDate(); | |||
| } | |||
| @Scheduled(cron = "0 5 0 * * ?") // 每天凌晨00:05 | |||
| //@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 | |||
| public void couponOrderRefundSchedule() { | |||
| List<WxCouponOrder> list = wxCouponOrderMapper.findExpiredCouponOrderByValidDate(); | |||
| for(WxCouponOrder co:list) { | |||
| WxAppinfo appinfo = new WxAppinfo(); | |||
| appinfo.setTenantId(co.getOrderId().toString()); | |||
| appinfo.setType(EnumAppType.B.getCode()); | |||
| appinfo = wxAppinfoMapper.findList(appinfo).get(0); | |||
| try { | |||
| wxRefundOrderService.createRefundOrder(payProperty.isReal(), appinfo, co.getId(), EnumRefundWay.AUTO, null); | |||
| } catch (Exception e) { | |||
| logger.error("退款失败:"+e.getMessage()+"couponOrderId="+co.getId()); | |||
| continue; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -1,15 +1,8 @@ | |||
| package com.simple.schedule; | |||
| import com.simple.domain.po.WxCouponOrder; | |||
| import com.simple.domain.po.WxMall; | |||
| import com.simple.domain.po.WxMerchant; | |||
| import com.simple.domain.po.WxOrder; | |||
| import com.simple.enums.EnumOrderStatus; | |||
| import com.simple.mapper.WxCouponOrderMapper; | |||
| import com.simple.mapper.WxMallMapper; | |||
| import com.simple.mapper.WxMerchantMapper; | |||
| import com.simple.mapper.WxOrderMapper; | |||
| import com.simple.service.WxDateAmountRecordService; | |||
| import org.apache.log4j.Logger; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.scheduling.annotation.Scheduled; | |||
| @@ -17,17 +10,15 @@ import org.springframework.stereotype.Component; | |||
| import org.springframework.transaction.annotation.Propagation; | |||
| import org.springframework.transaction.annotation.Transactional; | |||
| import java.text.ParseException; | |||
| import java.text.SimpleDateFormat; | |||
| import java.util.Date; | |||
| import java.util.HashMap; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| @Component | |||
| public class OrderExpireSchedule { | |||
| public class OrderExpiringSchedule { | |||
| private final Logger logger = Logger.getLogger(OrderExpireSchedule.class); | |||
| private final Logger logger = Logger.getLogger(OrderExpiringSchedule.class); | |||
| private final int TIME_OUT_VALUE = 15 * 60 * 1000; //15分钟 | |||
| @@ -39,4 +39,5 @@ mapper: | |||
| - com.simple.common.CommonMapper | |||
| pay: | |||
| real: true | |||
| real: true | |||
| share: false | |||
| @@ -14,6 +14,11 @@ public class PayProperty { | |||
| */ | |||
| private boolean real; | |||
| /** | |||
| * 是否分账 | |||
| */ | |||
| private boolean share; | |||
| public boolean isReal() { | |||
| return real; | |||
| } | |||
| @@ -21,4 +26,12 @@ public class PayProperty { | |||
| public void setReal(boolean real) { | |||
| this.real = real; | |||
| } | |||
| public boolean isShare() { | |||
| return share; | |||
| } | |||
| public void setShare(boolean share) { | |||
| this.share = share; | |||
| } | |||
| } | |||
| @@ -6,17 +6,14 @@ import java.text.SimpleDateFormat; | |||
| import java.util.Date; | |||
| import cn.binarywang.wx.miniapp.api.WxMaService; | |||
| import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl; | |||
| import cn.binarywang.wx.miniapp.config.WxMaInMemoryConfig; | |||
| import com.simple.common.ErrorCode; | |||
| import com.simple.domain.po.WxAppinfo; | |||
| import com.simple.domain.po.WxCUser; | |||
| import com.simple.domain.po.WxMerchantBUser; | |||
| import com.simple.exception.MallinkException; | |||
| import com.simple.interceptor.AuthorizationInterceptor; | |||
| import com.simple.service.WxAppinfoService; | |||
| import com.simple.service.WxCUserService; | |||
| import com.simple.service.WxMerchantBUserService; | |||
| import com.simple.utils.MaUtil; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.WebDataBinder; | |||
| import org.springframework.web.bind.annotation.InitBinder; | |||
| @@ -56,20 +53,23 @@ public class BaseController { | |||
| }); | |||
| } | |||
| public Long getUserId() { | |||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||
| Long bUserId = (Long) request.getAttribute(AuthorizationInterceptor.LOGIN_USER_KEY); | |||
| return bUserId; | |||
| } | |||
| public WxMerchantBUser getUser() { | |||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||
| Long cUserId = (Long) request.getAttribute(AuthorizationInterceptor.LOGIN_USER_KEY); | |||
| WxMerchantBUser user = wxMerchantBUserService.getById(cUserId); | |||
| Long bUserId = getUserId(); | |||
| WxMerchantBUser user = wxMerchantBUserService.getById(bUserId); | |||
| if (user == null) | |||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | |||
| return user; | |||
| } | |||
| public String getTenantId() { | |||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||
| Long cUserId = (Long) request.getAttribute(AuthorizationInterceptor.LOGIN_USER_KEY); | |||
| WxMerchantBUser user = wxMerchantBUserService.getById(cUserId); | |||
| Long bUserId = getUserId(); | |||
| WxMerchantBUser user = wxMerchantBUserService.getById(bUserId); | |||
| if (user == null) | |||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | |||
| return user.getTenantId(); | |||
| @@ -80,31 +80,13 @@ public class BaseController { | |||
| } | |||
| public WxMaService getWeappService(String appId) { | |||
| WxAppinfo appinfo = wxAppinfoService.getByAppId(appId); | |||
| WxMaInMemoryConfig config = new WxMaInMemoryConfig(); | |||
| config.setAppid(appinfo.getAppId()); | |||
| config.setSecret(appinfo.getSecret()); | |||
| config.setToken(appinfo.getToken()); | |||
| config.setAesKey(appinfo.getAesKey()); | |||
| config.setMsgDataFormat(appinfo.getMsgDataFormat()); | |||
| WxMaService service = new WxMaServiceImpl(); | |||
| service.setWxMaConfig(config); | |||
| WxMaService service = MaUtil.getWeappService(appinfo); | |||
| return service; | |||
| } | |||
| public WxMaService getWeappServiceByAppInfo(WxAppinfo appinfo) { | |||
| WxMaInMemoryConfig config = new WxMaInMemoryConfig(); | |||
| config.setAppid(appinfo.getAppId()); | |||
| config.setSecret(appinfo.getSecret()); | |||
| config.setToken(appinfo.getToken()); | |||
| config.setAesKey(appinfo.getAesKey()); | |||
| config.setMsgDataFormat(appinfo.getMsgDataFormat()); | |||
| WxMaService service = new WxMaServiceImpl(); | |||
| service.setWxMaConfig(config); | |||
| WxMaService service = MaUtil.getWeappService(appinfo); | |||
| return service; | |||
| } | |||
| } | |||
| @@ -130,35 +130,6 @@ public class WxCouponOrderController extends BaseController { | |||
| } | |||
| } | |||
| @ApiOperation(value = "退券接口", notes = "{\"couponOrderId\":\"string\"}") | |||
| @PostMapping("refund") | |||
| public ResultData refund(@RequestBody Map<String, String> paramMap) { | |||
| logger.info(paramMap.toString()); | |||
| String couponOrderIdStr = paramMap.get("couponOrderId"); | |||
| if (StringUtils.isBlank(couponOrderIdStr)) { | |||
| logger.error("couponOrderId不能为空: " + paramMap.toString()); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| Long couponOrderId = 0L; | |||
| try { | |||
| couponOrderId = Long.valueOf(couponOrderIdStr); | |||
| } catch (NumberFormatException e) { | |||
| logger.error("couponOrderId参数不正确: " + paramMap.toString()); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| try { | |||
| ResultData rd = wxCouponOrderService.refund(couponOrderId, getUser().getId()); | |||
| return rd; | |||
| } catch (MallinkException e) { | |||
| logger.error("退券异常: " + e.getMessage()); | |||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||
| } catch (Exception e) { | |||
| logger.error("退券异常: " + e.getMessage()); | |||
| return new ResultData(ErrorCode.REFUND_ORDER_ERROR, e.getMessage()); | |||
| } | |||
| } | |||
| @ApiOperation(value = "根据couponOrderId查询接口", notes = "{\"couponOrderId\":\"string\"}") | |||
| @PostMapping("/findById") | |||
| public ResultData findById(@RequestBody Map<String, String> paramMap) { | |||
| @@ -8,6 +8,7 @@ import com.simple.config.PayProperty; | |||
| import com.simple.domain.po.*; | |||
| import com.simple.enums.EnumPayStatus; | |||
| import com.simple.enums.EnumPayWay; | |||
| import com.simple.enums.EnumRefundWay; | |||
| import com.simple.exception.MallinkException; | |||
| import com.simple.service.*; | |||
| import io.swagger.annotations.Api; | |||
| @@ -42,68 +43,29 @@ public class WxRefundOrderController extends BaseController { | |||
| @Autowired | |||
| private WxRefundOrderService wxRefundOrderService; | |||
| @ApiOperation(value = "发起退款", notes = "{\"orderId\":\"string\"}") | |||
| @ApiOperation(value = "退券退款", notes = "{\"couponOrderId\":\"string\"}") | |||
| @PostMapping("/create") | |||
| public ResultData create(@RequestBody Map<String, String> paramMap) { | |||
| // couponOrder发起退款 | |||
| logger.info("/api/refund/create" + paramMap.toString()); | |||
| //Assert.notNull(wxRefundOrder.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| String orderIdStr = paramMap.get("orderId"); | |||
| if (StringUtils.isBlank(orderIdStr)) { | |||
| logger.error("orderId不能为空: " + paramMap.toString()); | |||
| logger.info(paramMap.toString()); | |||
| String couponOrderIdStr = paramMap.get("couponOrderId"); | |||
| if (StringUtils.isBlank(couponOrderIdStr)) { | |||
| logger.error("couponOrderId不能为空: " + paramMap.toString()); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| Long orderId = 0L; | |||
| Long couponOrderId = 0L; | |||
| try { | |||
| orderId = Long.valueOf(orderIdStr); | |||
| couponOrderId = Long.valueOf(couponOrderIdStr); | |||
| } catch (NumberFormatException e) { | |||
| logger.error("orderId参数不正确: " + paramMap.toString()); | |||
| logger.error("couponOrderId参数不正确: " + paramMap.toString()); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| WxOrder order = null; | |||
| try { | |||
| order = wxOrderService.getById(orderId); | |||
| } catch (Exception e) { | |||
| logger.error("订单不存在: " + orderIdStr); | |||
| return new ResultData(ErrorCode.ORDER_IS_NOT_FIND.getCode(), "订单不存在: " + orderIdStr); | |||
| } | |||
| if (order == null) { | |||
| logger.error("订单不存在: " + orderIdStr); | |||
| return new ResultData(ErrorCode.ORDER_IS_NOT_FIND.getCode(), "订单不存在: " + orderIdStr); | |||
| } | |||
| if (order.getPayment() <= 0) { | |||
| logger.error("订单支付金额小于等于0: " + order.toString()); | |||
| throw new MallinkException(ErrorCode.REFUND_PAY_ORDER_IS_ZERO); | |||
| } | |||
| WxPayOrder payOrderQ = new WxPayOrder(); | |||
| payOrderQ.setCUserId(order.getCUserId()); | |||
| payOrderQ.setOrderId(orderId); | |||
| payOrderQ.setPayOrderStatus(EnumPayStatus.PAY_WAY_SUCCESS.getCode()); | |||
| WxPayOrder payOrder = null; | |||
| try { | |||
| payOrder = wxPayOrderService.getByObj(payOrderQ); | |||
| } catch (Exception e) { | |||
| logger.error("支付订单不存在(payOrder不存在)"); | |||
| return new ResultData(ErrorCode.PAY_ORDER_NOT_FOUND); | |||
| } | |||
| if (payOrder == null) { | |||
| logger.error("支付订单不存在(payOrder不存在)"); | |||
| return new ResultData(ErrorCode.PAY_ORDER_NOT_FOUND); | |||
| } | |||
| WxRefundOrder refundOrderQ = new WxRefundOrder(); | |||
| refundOrderQ.setPayOrderNo(String.valueOf(payOrder.getId())); | |||
| refundOrderQ.setOrderId(orderId); | |||
| WxMerchantBUser bUser = getUser(); | |||
| WxAppinfo appinfo = getAppInfo(bUser.getAppId()); | |||
| try { | |||
| wxRefundOrderService.createRefundOrder(payProperty.isReal(), appinfo, refundOrderQ, payOrder, EnumPayWay.PAY_WAY_WEAPP); | |||
| wxRefundOrderService.createRefundOrder(payProperty.isReal(), appinfo, couponOrderId, EnumRefundWay.B, bUser.getId()); | |||
| return new ResultData(); | |||
| } catch (MallinkException e) { | |||
| logger.error(e.getMessage()); | |||
| @@ -39,4 +39,5 @@ mapper: | |||
| - com.simple.common.CommonMapper | |||
| pay: | |||
| real: true | |||
| real: true | |||
| share: false | |||
| @@ -16,6 +16,11 @@ public class PayProperty { | |||
| */ | |||
| private boolean real; | |||
| /** | |||
| * 是否分账 | |||
| */ | |||
| private boolean share; | |||
| public boolean isReal() { | |||
| return real; | |||
| } | |||
| @@ -23,4 +28,12 @@ public class PayProperty { | |||
| public void setReal(boolean real) { | |||
| this.real = real; | |||
| } | |||
| public boolean isShare() { | |||
| return share; | |||
| } | |||
| public void setShare(boolean share) { | |||
| this.share = share; | |||
| } | |||
| } | |||
| @@ -16,6 +16,7 @@ import com.simple.exception.MallinkException; | |||
| import com.simple.interceptor.AuthorizationInterceptor; | |||
| import com.simple.service.WxAppinfoService; | |||
| import com.simple.service.WxCUserService; | |||
| import com.simple.utils.MaUtil; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.WebDataBinder; | |||
| import org.springframework.web.bind.annotation.InitBinder; | |||
| @@ -56,8 +57,7 @@ public class BaseController { | |||
| } | |||
| public WxCUser getUser(){ | |||
| HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest(); | |||
| Long cUserId = (Long)request.getAttribute(AuthorizationInterceptor.LOGIN_USER_KEY); | |||
| Long cUserId = getUserId(); | |||
| WxCUser user = wxCUserService.getById(cUserId); | |||
| if (user == null) | |||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | |||
| @@ -71,8 +71,7 @@ public class BaseController { | |||
| } | |||
| public String getTenantId(){ | |||
| HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest(); | |||
| Long cUserId = (Long)request.getAttribute(AuthorizationInterceptor.LOGIN_USER_KEY); | |||
| Long cUserId = getUserId(); | |||
| WxCUser user = wxCUserService.getById(cUserId); | |||
| if (user == null) | |||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | |||
| @@ -80,36 +79,17 @@ public class BaseController { | |||
| } | |||
| public WxAppinfo getAppInfo(String appId) { | |||
| return wxAppinfoService.getByAppId(appId); | |||
| } | |||
| public WxMaService getWeappService(String appId) { | |||
| WxAppinfo appinfo = wxAppinfoService.getByAppId(appId); | |||
| WxMaInMemoryConfig config = new WxMaInMemoryConfig(); | |||
| config.setAppid(appinfo.getAppId()); | |||
| config.setSecret(appinfo.getSecret()); | |||
| config.setToken(appinfo.getToken()); | |||
| config.setAesKey(appinfo.getAesKey()); | |||
| config.setMsgDataFormat(appinfo.getMsgDataFormat()); | |||
| WxMaService service = new WxMaServiceImpl(); | |||
| service.setWxMaConfig(config); | |||
| WxMaService service = MaUtil.getWeappService(appinfo); | |||
| return service; | |||
| } | |||
| public WxMaService getWeappServiceByAppInfo(WxAppinfo appinfo) { | |||
| WxMaInMemoryConfig config = new WxMaInMemoryConfig(); | |||
| config.setAppid(appinfo.getAppId()); | |||
| config.setSecret(appinfo.getSecret()); | |||
| config.setToken(appinfo.getToken()); | |||
| config.setAesKey(appinfo.getAesKey()); | |||
| config.setMsgDataFormat(appinfo.getMsgDataFormat()); | |||
| WxMaService service = new WxMaServiceImpl(); | |||
| service.setWxMaConfig(config); | |||
| WxMaService service = MaUtil.getWeappService(appinfo); | |||
| return service; | |||
| } | |||
| } | |||
| @@ -32,7 +32,6 @@ public class WxBusinessController extends BaseController { | |||
| public ResultData list(WxBusiness wxBusiness, Integer pageNum, Integer pageSize) { | |||
| if (null == wxBusiness) wxBusiness = new WxBusiness(); | |||
| WxCUser user = getUser(); | |||
| wxBusiness.setTenantId(user.getTenantId()); | |||
| final PageInfo<WxBusiness> page = wxBusinessService.listAsPage(wxBusiness, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @@ -7,12 +7,9 @@ import com.simple.common.ErrorCode; | |||
| import com.simple.common.Result; | |||
| import com.simple.common.ResultData; | |||
| import com.simple.domain.po.*; | |||
| import com.simple.enums.EnumCarVendor; | |||
| import com.simple.enums.EnumETCPCode; | |||
| import com.simple.enums.EnumTJDCode; | |||
| import com.simple.service.WxCUserCarService; | |||
| import com.simple.service.WxMerchantService; | |||
| import com.simple.service.WxParkService; | |||
| import com.simple.domain.vo.WxCouponOrderCarCVo; | |||
| import com.simple.enums.*; | |||
| import com.simple.service.*; | |||
| import com.simple.utils.ETCPUtil; | |||
| import com.simple.utils.TJDCarUtil; | |||
| import io.swagger.annotations.Api; | |||
| @@ -49,6 +46,9 @@ public class WxCarController extends BaseController | |||
| @Autowired | |||
| WxMerchantService wxMerchantService; | |||
| @Autowired | |||
| WxCouponOrderService wxCouponOrderService; | |||
| private WxPark getCurrentPark(WxCUser user) { | |||
| WxPark parkQ = new WxPark(); | |||
| parkQ.setTenantId(user.getTenantId()); | |||
| @@ -587,7 +587,7 @@ public class WxCarController extends BaseController | |||
| * 优免券领取 | |||
| * 优免券不可退 | |||
| */ | |||
| @ApiOperation(value = "优免券领取", notes="ETCP:={\"etcpToken\":\"string\",\"carNumber\":\"string\",\"couponFreeId\":\"string\"},输出\n{}") | |||
| @ApiOperation(value = "优免券领取", notes="ETCP:={\"etcpToken\":\"string\",\"carNumber\":\"string\",\"couponOrderId\"=\"String\"},输出\n{}") | |||
| @PostMapping("/getCoupon") | |||
| public ResultData getCoupon(@RequestBody Map<String, String > paramMap) { | |||
| WxCUser user = getUser(); | |||
| @@ -596,39 +596,65 @@ public class WxCarController extends BaseController | |||
| if (park.getVendorType() == EnumCarVendor.CAR_ETCP.getCode()) { | |||
| String etcpToken = paramMap.get("etcpToken"); | |||
| String carNumber = paramMap.get("carNumber"); | |||
| String couponFreeId = paramMap.get("couponFreeId"); | |||
| String merchantIdStr = paramMap.get("merchantId"); | |||
| String couponOrderIdStr = paramMap.get("couponOrderId"); | |||
| if (StringUtils.isBlank(etcpToken)) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "etcpToken为空"); | |||
| } | |||
| if (StringUtils.isBlank(carNumber)) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "carNumber为空"); | |||
| } | |||
| if (StringUtils.isBlank(couponFreeId)) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponFreeId为空"); | |||
| if (StringUtils.isBlank(couponOrderIdStr)) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponOrderId为空"); | |||
| } | |||
| Long couponOrderId = 0L; | |||
| try { | |||
| couponOrderId = Long.valueOf(couponOrderIdStr); | |||
| } catch (NumberFormatException e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponOrderId转化失败"); | |||
| } | |||
| if (StringUtils.isBlank(merchantIdStr)) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "merchantId为空"); | |||
| WxCouponOrderCarCVo userCar = null; | |||
| WxCouponOrderCarCVo userCarQ = new WxCouponOrderCarCVo(); | |||
| userCarQ.setTenantId(user.getTenantId()); | |||
| userCarQ.setId(couponOrderId); | |||
| List<WxCouponOrderCarCVo> list = wxCouponOrderService.carlistCUserVo(userCarQ); | |||
| if (list.size() > 0) { | |||
| userCar = list.get(0); | |||
| } | |||
| String params = park.getVendorParams(); | |||
| JSONObject objParams = JSON.parseObject(params); | |||
| String url = objParams.getString("url"); | |||
| String merchantNo = objParams.getString("merchantNo"); | |||
| String merchantKey = objParams.getString("merchantKey"); | |||
| String version = objParams.getString("version"); | |||
| String parkId = objParams.getString("parkId"); | |||
| String businessId = ""; | |||
| // 优先从从商户表里取 | |||
| businessId = getETCPBusinessID(merchantIdStr); | |||
| businessId = getETCPBusinessID(String.valueOf(userCar.getMerchantId())); | |||
| if (StringUtils.isBlank(businessId)) { | |||
| // 1期只有一个虚拟商户,可以写在商场配置里 | |||
| businessId = objParams.getString("businessId"); | |||
| } | |||
| String ret = etcp.bCouponRecord(url, merchantNo, merchantKey, version, | |||
| etcpToken, parkId, businessId, carNumber, couponFreeId); | |||
| etcpToken, park.getParkId(), businessId, carNumber, String.valueOf(userCar.getCouponFreeId())); | |||
| JSONObject retObj = JSON.parseObject(ret); | |||
| if (retObj.getIntValue("code") == EnumETCPCode.SUCCESS.getCode()) { | |||
| // 券状态设为已使用 | |||
| WxCouponOrder couponOrder = new WxCouponOrder(); | |||
| couponOrder.setId(userCar.getId()); | |||
| couponOrder.setTenantId(user.getTenantId()); | |||
| couponOrder.setUpdateDate(new Date()); | |||
| couponOrder.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USED.getCode()); | |||
| try { | |||
| wxCouponOrderService.saveOrUpdate(couponOrder); | |||
| } catch (Exception e) { | |||
| logger.error("券包状态更新失败:" + couponOrderIdStr); | |||
| return new ResultData(ErrorCode.DB_FAIL.getCode(), "券包状态更新失败"); | |||
| } | |||
| return new ResultData(); | |||
| } else { | |||
| return new ResultData(ErrorCode.ETCP_QUAN_SEND_FAIL.getCode(), retObj.getString("message")); | |||
| @@ -636,4 +662,28 @@ public class WxCarController extends BaseController | |||
| } | |||
| return new ResultData(ErrorCode.CAR_VENDOR_NOT_SUPPORT.getCode(), "优免券领取失败"); | |||
| } | |||
| @ApiOperation("券包分页列表接口") | |||
| @GetMapping("couponOrderList") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true), | |||
| }) | |||
| public ResultData list(@ModelAttribute WxCouponOrderCarCVo wxCouponOrder, Integer pageNum, Integer pageSize) { | |||
| if(pageNum == null || pageSize == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| if (wxCouponOrder == null) wxCouponOrder = new WxCouponOrderCarCVo(); | |||
| WxCUser user = getUser(); | |||
| wxCouponOrder.setTenantId(user.getTenantId()); | |||
| wxCouponOrder.setCUserId(user.getId()); | |||
| if (wxCouponOrder.getCouponOrderStatus() == null) | |||
| wxCouponOrder.setSortColumns(WxCouponOrder.Field.CreateDate_DESC); | |||
| else if (wxCouponOrder.getCouponOrderStatus() == EnumCouponOrderStatus.COUPON_ORDER_USE_WAIT.getCode()) | |||
| wxCouponOrder.setSortColumns(WxCouponOrder.Field.CreateDate_DESC); | |||
| else | |||
| wxCouponOrder.setSortColumns(WxCouponOrder.Field.UpdateDate_DESC); | |||
| return wxCouponOrderService.carlistCUserVoAsPage(wxCouponOrder, pageNum, pageSize); | |||
| } | |||
| } | |||
| @@ -31,46 +31,18 @@ public class WxCouponOrderController extends BaseController { | |||
| @Autowired | |||
| private WxCouponOrderService wxCouponOrderService; | |||
| @ApiOperation(value = "退券接口", notes = "{\"couponOrderId\":\"string\"}") | |||
| @PostMapping("refund") | |||
| public ResultData refund(@RequestBody Map<String, String> paramMap) { | |||
| logger.info(paramMap.toString()); | |||
| String couponOrderIdStr = paramMap.get("couponOrderId"); | |||
| if (StringUtils.isBlank(couponOrderIdStr)) { | |||
| logger.error("couponOrderId不能为空: " + paramMap.toString()); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponOrderId不能为空"); | |||
| } | |||
| Long couponOrderId = 0L; | |||
| try { | |||
| couponOrderId = Long.valueOf(couponOrderIdStr); | |||
| } catch (NumberFormatException e) { | |||
| logger.error("couponOrderId参数不正确: " + paramMap.toString()); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponOrderId参数不正确"); | |||
| } | |||
| try { | |||
| ResultData rd = wxCouponOrderService.refund(couponOrderId, getUser().getId()); | |||
| return rd; | |||
| } catch (MallinkException e) { | |||
| logger.error("退券异常: " + e.getMessage()); | |||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||
| } catch (Exception e) { | |||
| logger.error("退券异常: " + e.getMessage()); | |||
| return new ResultData(ErrorCode.REFUND_ORDER_ERROR, e.getMessage()); | |||
| } | |||
| } | |||
| @ApiOperation("券包分页列表接口") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true), | |||
| }) | |||
| public ResultData list(@ModelAttribute WxCouponOrder wxCouponOrder, Integer pageNum, Integer pageSize) { | |||
| public ResultData list(@ModelAttribute WxCouponOrderCVo wxCouponOrder, Integer pageNum, Integer pageSize) { | |||
| if(pageNum == null || pageSize == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| if (wxCouponOrder == null) wxCouponOrder = new WxCouponOrder(); | |||
| if (wxCouponOrder == null) wxCouponOrder = new WxCouponOrderCVo(); | |||
| wxCouponOrder.setCUserId(getUser().getId()); | |||
| if (wxCouponOrder.getCouponOrderStatus() == null) | |||
| wxCouponOrder.setSortColumns(WxCouponOrder.Field.CreateDate_DESC); | |||
| @@ -72,7 +72,7 @@ public class WxPayOrderController extends BaseController { | |||
| try { | |||
| record.setIp(IPUtil.getIpAddr(request)); | |||
| return wxPayOrderService.createPayOrder(payProperty.isReal(), appInfo, user, record, EnumPayWay.PAY_WAY_WECHAT); | |||
| return wxPayOrderService.createPayOrder(payProperty.isReal(), payProperty.isShare(), appInfo, user, record, EnumPayWay.PAY_WAY_WECHAT); | |||
| } catch (MallinkException e) { | |||
| logger.error("payment wechat, order create error, req 2: " + record.toString() + ", e:" + e.getMessage()); | |||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||
| @@ -342,6 +342,7 @@ public class WxUserGrantController extends BaseController { | |||
| * @param request | |||
| * @throws IOException | |||
| */ | |||
| @AuthIgnore | |||
| @RequestMapping(value = "/signature") | |||
| @ResponseBody | |||
| public void signature(HttpServletResponse response, HttpServletRequest request) throws IOException { | |||
| @@ -352,16 +353,15 @@ public class WxUserGrantController extends BaseController { | |||
| String nonce = request.getParameter("nonce"); | |||
| String echostr = request.getParameter("echostr"); | |||
| logger.warn("收到的微信服务验证信息"+signature+"\n"+timestamp+"\n"+nonce+"\n"+echostr); | |||
| logger.warn("收到的微信服务验证信息:"+signature+"\n"+timestamp+"\n"+nonce+"\n"+echostr); | |||
| PrintWriter out = response.getWriter(); | |||
| /* | |||
| // 通过检验signature对请求进行校验,若校验成功则原样返回echostr,表示接入成功,否则接入失败 | |||
| if (CheckUtil.checkSignature(wp.getToken(), signature, timestamp, nonce)) { | |||
| // 当前无法确定此消息的appId及token, 所以直接返回echostr | |||
| //if (CheckUtil.checkSignature(wp.getToken(), signature, timestamp, nonce)) { | |||
| out.print(echostr); | |||
| logger.warn("微信服务验证成功===================="+echostr); | |||
| System.out.println("微信服务验证成功!"); | |||
| } | |||
| */ | |||
| //} | |||
| out.close(); | |||
| } | |||
| @@ -40,3 +40,4 @@ mapper: | |||
| pay: | |||
| real: true | |||
| share: false | |||
| @@ -113,6 +113,7 @@ public enum ErrorCode{ | |||
| COUPON_ORDER_IS_USED(4001, "卡券已核销"), | |||
| COUPON_ORDER_IS_OVER_TIME(4002, "卡券已过期"), | |||
| COUPON_ORDER_IS_INVALID(4003, "卡券已经作废"), | |||
| COUPON_ORDER_BUSER_IS_NULL(4004, "卡券B端用户不存在"), | |||
| /** | |||
| @@ -124,6 +125,7 @@ public enum ErrorCode{ | |||
| NICK_NAME_NOT_FOUND(11004, "nickName,unionId未授权"), | |||
| PHONE_NOT_FOUND(11005, "Phone未授权"), | |||
| PHONE_IS_ENCRYPTED(11006, "Phone已加密"), | |||
| TEMPLATE_SEND_FAILED(11007, "模板消息发送失败"), | |||
| /** | |||
| @@ -155,6 +157,8 @@ public enum ErrorCode{ | |||
| PROFIT_SHARING_QUERY_REQUEST_FAILED(12034, "分账查询请求失败"), | |||
| PROFIT_SHARING_QUERY_APPLY_FAILED(12035, "分账查询业务失败"), | |||
| PROFIT_SHARING_QUERY_RETURN_INVALID(12036, "分账查询返回校验失败"), | |||
| PROFIT_SHARING_RECEIVER_ADD_FAILED(12037, "分账账户添加失败"), | |||
| PROFIT_SHARING_RECEIVER_DEL_FAILED(12037, "分账账户删除失败"), | |||
| /** | |||
| * 核销 | |||
| */ | |||
| @@ -165,10 +169,25 @@ public enum ErrorCode{ | |||
| * 解单 | |||
| */ | |||
| DALIY_REPORT_VOLUME_TODAY_NULL(12070, "今日解单不存在"), | |||
| DALIY_REPORT_VOLUME_WEEK_NULL(12071, "无解单数据") | |||
| ; | |||
| DALIY_REPORT_VOLUME_WEEK_NULL(12071, "无解单数据"), | |||
| /** | |||
| * 模板消息 | |||
| */ | |||
| TEMPLATE_NOT_FOUND(12090, "模板不存在"), | |||
| /** | |||
| * | |||
| * 短信 | |||
| * | |||
| * */ | |||
| MSG_SERVER_NOT_FIND(12100,"您还未接入短信运营商,请联系平台管理员"), | |||
| MSG_TEMPLATE_REPEAT(12101,"您添加的短信模板已存在"), | |||
| MSG_SIGNATURE_CONTENT_ERROR(12102,"短信签名或内容错误"), | |||
| MSG_TEMPLATE_CREATE_ERROR(12103,"创建模板失败"), | |||
| ; | |||
| private int code; | |||
| private String message; | |||
| @@ -47,6 +47,9 @@ public class WxAppinfo implements Serializable { | |||
| /*小程序ID**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="小程序ID",name="appId") | |||
| private String appId; | |||
| /*公众号ID**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="公众号ID",name="parentAppId") | |||
| private String parentAppId; | |||
| /*小程序名**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="小程序名",name="name") | |||
| private String name; | |||
| @@ -80,7 +83,6 @@ public class WxAppinfo implements Serializable { | |||
| public String getTenantId() { | |||
| return tenantId; | |||
| } | |||
| public void setTenantId(String _tenantId) { | |||
| tenantId = _tenantId; | |||
| } | |||
| @@ -90,6 +92,13 @@ public class WxAppinfo implements Serializable { | |||
| public void setAppId(String _appId) { | |||
| appId = _appId; | |||
| } | |||
| public String getParentAppId() { | |||
| return parentAppId; | |||
| } | |||
| public void setParentAppId(String parentAppId) { | |||
| this.parentAppId = parentAppId; | |||
| } | |||
| public String getName() { | |||
| return name; | |||
| } | |||
| @@ -156,17 +165,18 @@ public class WxAppinfo implements Serializable { | |||
| public static enum Field | |||
| { | |||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||
| ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") | |||
| ,AppId_ASC("`appId` ASC"),AppId_DESC("`appId` DESC") | |||
| ,TenantId_ASC("`tenant_id` ASC"),TenantId_DESC("`tenant_id` DESC") | |||
| ,AppId_ASC("`app_id` ASC"),AppId_DESC("`app_id` DESC") | |||
| ,ParentAppId_ASC("`parent_app_id` ASC"),ParentAppId_DESC("`parent_app_id` DESC") | |||
| ,Name_ASC("`name` ASC"),Name_DESC("`name` DESC") | |||
| ,Secret_ASC("`secret` ASC"),Secret_DESC("`secret` DESC") | |||
| ,Token_ASC("`token` ASC"),Token_DESC("`token` DESC") | |||
| ,AesKey_ASC("`aesKey` ASC"),AesKey_DESC("`aesKey` DESC") | |||
| ,MsgDataFormat_ASC("`msgDataFormat` ASC"),MsgDataFormat_DESC("`msgDataFormat` DESC") | |||
| ,AccessToken_ASC("`accessToken` ASC"),AccessToken_DESC("`accessToken` DESC") | |||
| ,LastTokenTime_ASC("`lastTokenTime` ASC"),LastTokenTime_DESC("`lastTokenTime` DESC") | |||
| ,ExpiresIn_ASC("`expiresIn` ASC"),ExpiresIn_DESC("`expiresIn` DESC") | |||
| ,PayId_ASC("`payId` ASC"),PayId_DESC("`payId` DESC") | |||
| ,MsgDataFormat_ASC("`msg_data_format` ASC"),MsgDataFormat_DESC("`msg_data_format` DESC") | |||
| ,AccessToken_ASC("`access_token` ASC"),AccessToken_DESC("`access_token` DESC") | |||
| ,LastTokenTime_ASC("`last_token_time` ASC"),LastTokenTime_DESC("`last_token_time` DESC") | |||
| ,ExpiresIn_ASC("`expires_in` ASC"),ExpiresIn_DESC("`expires_in` DESC") | |||
| ,PayId_ASC("`pay_id` ASC"),PayId_DESC("`pay_id` DESC") | |||
| ,Type_ASC("`type` ASC"),Type_DESC("`type` DESC") | |||
| ; | |||
| @@ -201,7 +211,7 @@ public class WxAppinfo implements Serializable { | |||
| sb.append(","); | |||
| sb.append(fields[k].toString()); | |||
| } | |||
| this.sortColumns = sb.toString(); | |||
| } | |||
| public void setSortColumns(String sortColumns) | |||
| @@ -41,9 +41,6 @@ public class WxBusiness implements Serializable { | |||
| /*租户ID**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") | |||
| private String tenantId; | |||
| /*业态名**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="业态名",name="title") | |||
| private String title; | |||
| @@ -56,12 +53,6 @@ public class WxBusiness implements Serializable { | |||
| /*更新时间**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | |||
| private Date updateDate; | |||
| public String getTenantId() { | |||
| return tenantId; | |||
| } | |||
| public void setTenantId(String _tenantId) { | |||
| tenantId = _tenantId; | |||
| } | |||
| public String getTitle() { | |||
| return title; | |||
| } | |||
| @@ -92,11 +83,10 @@ public class WxBusiness implements Serializable { | |||
| public static enum Field | |||
| { | |||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||
| ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") | |||
| ,Title_ASC("`title` ASC"),Title_DESC("`title` DESC") | |||
| ,Type_ASC("`type` ASC"),Type_DESC("`type` DESC") | |||
| ,CreateDate_ASC("`createDate` ASC"),CreateDate_DESC("`createDate` DESC") | |||
| ,UpdateDate_ASC("`updateDate` ASC"),UpdateDate_DESC("`updateDate` DESC") | |||
| ,CreateDate_ASC("`create_date` ASC"),CreateDate_DESC("`create_date` DESC") | |||
| ,UpdateDate_ASC("`update_date` ASC"),UpdateDate_DESC("`update_date` DESC") | |||
| ; | |||
| private String value; | |||
| Field(String value){ | |||
| @@ -129,6 +119,8 @@ public class WxBusiness implements Serializable { | |||
| sb.append(","); | |||
| sb.append(fields[k].toString()); | |||
| } | |||
| this.sortColumns = sb.toString(); | |||
| } | |||
| @@ -41,9 +41,6 @@ public class WxChannel implements Serializable { | |||
| /***/ | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="tenantId") | |||
| private Long tenantId; | |||
| /*渠道ID**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="渠道ID",name="channelId") | |||
| private Integer channelId; | |||
| @@ -53,12 +50,6 @@ public class WxChannel implements Serializable { | |||
| /*图片url**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="图片url",name="img") | |||
| private String img; | |||
| public Long getTenantId() { | |||
| return tenantId; | |||
| } | |||
| public void setTenantId(Long _tenantId) { | |||
| tenantId = _tenantId; | |||
| } | |||
| public Integer getChannelId() { | |||
| return channelId; | |||
| } | |||
| @@ -83,8 +74,7 @@ public class WxChannel implements Serializable { | |||
| public static enum Field | |||
| { | |||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||
| ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") | |||
| ,ChannelId_ASC("`channelId` ASC"),ChannelId_DESC("`channelId` DESC") | |||
| ,ChannelId_ASC("`channel_id` ASC"),ChannelId_DESC("`channel_id` DESC") | |||
| ,Title_ASC("`title` ASC"),Title_DESC("`title` DESC") | |||
| ,Img_ASC("`img` ASC"),Img_DESC("`img` DESC") | |||
| ; | |||
| @@ -119,6 +109,8 @@ public class WxChannel implements Serializable { | |||
| sb.append(","); | |||
| sb.append(fields[k].toString()); | |||
| } | |||
| this.sortColumns = sb.toString(); | |||
| } | |||
| @@ -0,0 +1,139 @@ | |||
| package com.simple.domain.po; | |||
| import javax.persistence.Id; | |||
| import javax.persistence.Table; | |||
| import javax.persistence.Transient; | |||
| import java.io.Serializable; | |||
| import java.util.ArrayList; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| @Table(name = "wx_mall_apply") | |||
| public class WxMallApply implements Serializable { | |||
| private static final long serialVersionUID = 1L; | |||
| @Id | |||
| protected Long id; | |||
| @Transient | |||
| protected List<String> ids; | |||
| @Transient | |||
| protected String sortColumns; | |||
| public Long getId() { | |||
| return id; | |||
| } | |||
| public void setId(Long id) { | |||
| this.id = id; | |||
| } | |||
| public String getSortColumns() { | |||
| return sortColumns; | |||
| } | |||
| public List<String> getIds() { | |||
| return ids; | |||
| } | |||
| public void setIds(List<String> ids) { | |||
| this.ids = ids; | |||
| } | |||
| /*购物中心名称**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="购物中心名称",name="mallName") | |||
| private String mallName; | |||
| /*联系人姓名**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="联系人姓名",name="applicant") | |||
| private String applicant; | |||
| /***/ | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="phone") | |||
| private String phone; | |||
| /*申请时间**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="申请时间",name="applyDate") | |||
| private Date applyDate; | |||
| public String getMallName() { | |||
| return mallName; | |||
| } | |||
| public void setMallName(String _mallName) { | |||
| mallName = _mallName; | |||
| } | |||
| public String getApplicant() { | |||
| return applicant; | |||
| } | |||
| public void setApplicant(String _applicant) { | |||
| applicant = _applicant; | |||
| } | |||
| public String getPhone() { | |||
| return phone; | |||
| } | |||
| public void setPhone(String _phone) { | |||
| phone = _phone; | |||
| } | |||
| public Date getApplyDate() { | |||
| return applyDate; | |||
| } | |||
| public void setApplyDate(Date _applyDate) { | |||
| applyDate = _applyDate; | |||
| } | |||
| public static enum Field | |||
| { | |||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||
| ,MallName_ASC("`mall_name` ASC"),MallName_DESC("`mall_name` DESC") | |||
| ,Applicant_ASC("`applicant` ASC"),Applicant_DESC("`applicant` DESC") | |||
| ,Phone_ASC("`phone` ASC"),Phone_DESC("`phone` DESC") | |||
| ,ApplyDate_ASC("`apply_date` ASC"),ApplyDate_DESC("`apply_date` DESC") | |||
| ; | |||
| private String value; | |||
| Field(String value){ | |||
| this.value = value; | |||
| } | |||
| public String getValue() { | |||
| return value; | |||
| } | |||
| public void setCol(String value) { | |||
| this.value = value; | |||
| } | |||
| @Override | |||
| public String toString() { | |||
| return this.getValue(); | |||
| } | |||
| } | |||
| public void setSortColumns(Field... fields) | |||
| { | |||
| if (fields == null || fields.length == 0) { | |||
| return; | |||
| } | |||
| for (int k = 0; k < fields.length; k++) { | |||
| if (fields[k] == null) { | |||
| return; | |||
| } | |||
| } | |||
| StringBuilder sb = new StringBuilder(fields[0].toString()); | |||
| for (int k = 1; k < fields.length; k++) { | |||
| sb.append(","); | |||
| sb.append(fields[k].toString()); | |||
| } | |||
| this.sortColumns=sb.toString(); | |||
| } | |||
| public void setSortColumns(String sortColumns) | |||
| { | |||
| if (sortColumns == null || "".equals(sortColumns.trim())) { | |||
| return; | |||
| } | |||
| if (sortColumns.contains(",")) { | |||
| String[] cols = sortColumns.split(","); | |||
| List<Field> fList = new ArrayList(); | |||
| for (int k = 0; k < cols.length; k++) { | |||
| fList.add(Field.valueOf(cols[k])); | |||
| } | |||
| this.setSortColumns(fList.toArray(new Field[fList.size()])); | |||
| } else { | |||
| this.setSortColumns(Field.valueOf(sortColumns)); | |||
| } | |||
| } | |||
| } | |||
| @@ -49,6 +49,13 @@ public class WxMerchant implements Serializable { | |||
| @Transient | |||
| private List<WxMerchantBUser> bUsers; | |||
| /*租期开始时间**/ | |||
| @Transient | |||
| private Date rentalStartDate; | |||
| /*租期结束时间**/ | |||
| @Transient | |||
| private Date rentalEndDate; | |||
| /*租户ID**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") | |||
| private String tenantId; | |||
| @@ -61,15 +68,6 @@ public class WxMerchant implements Serializable { | |||
| /*联系方式**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="联系方式",name="linkPhone") | |||
| private String linkPhone; | |||
| /*银行卡**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="银行卡",name="bankCard") | |||
| private String bankCard; | |||
| /*银行开户行**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="银行开户行",name="bankName") | |||
| private String bankName; | |||
| /*支付ID,参看wx_pay_account**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="收款帐户",name="receiver_account") | |||
| private Long receiverAccount; | |||
| /*创建时间**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | |||
| private Date createDate; | |||
| @@ -86,6 +84,10 @@ public class WxMerchant implements Serializable { | |||
| @io.swagger.annotations.ApiModelProperty(value="状态1可用0停用",name="status") | |||
| private Integer status; | |||
| @io.swagger.annotations.ApiModelProperty(value="联系人",name="linkPerson") | |||
| private String linkPerson; | |||
| public String getTenantId() { | |||
| return tenantId; | |||
| } | |||
| @@ -110,26 +112,6 @@ public class WxMerchant implements Serializable { | |||
| public void setLinkPhone(String _linkPhone) { | |||
| linkPhone = _linkPhone; | |||
| } | |||
| public String getBankCard() { | |||
| return bankCard; | |||
| } | |||
| public void setBankCard(String _bankCard) { | |||
| bankCard = _bankCard; | |||
| } | |||
| public String getBankName() { | |||
| return bankName; | |||
| } | |||
| public void setBankName(String _bankName) { | |||
| bankName = _bankName; | |||
| } | |||
| public Long getReceiverAccount() { | |||
| return receiverAccount; | |||
| } | |||
| public void setReceiverAccount(Long receiverAccount) { | |||
| this.receiverAccount = receiverAccount; | |||
| } | |||
| public Date getCreateDate() { | |||
| return createDate; | |||
| @@ -196,20 +178,41 @@ public class WxMerchant implements Serializable { | |||
| this.bUsers = bUsers; | |||
| } | |||
| public Date getRentalStartDate() { | |||
| return rentalStartDate; | |||
| } | |||
| public void setRentalStartDate(Date rentalStartDate) { | |||
| this.rentalStartDate = rentalStartDate; | |||
| } | |||
| public Date getRentalEndDate() { | |||
| return rentalEndDate; | |||
| } | |||
| public void setRentalEndDate(Date rentalEndDate) { | |||
| this.rentalEndDate = rentalEndDate; | |||
| } | |||
| public String getLinkPerson() { | |||
| return linkPerson; | |||
| } | |||
| public void setLinkPerson(String linkPerson) { | |||
| this.linkPerson = linkPerson; | |||
| } | |||
| public static enum Field | |||
| { | |||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||
| ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") | |||
| ,ImgUrl_ASC("`imgUrl` ASC"),ImgUrl_DESC("`imgUrl` DESC") | |||
| ,TenantId_ASC("`tenant_id` ASC"),TenantId_DESC("`tenant_id` DESC") | |||
| ,ImgUrl_ASC("`img_url` ASC"),ImgUrl_DESC("`img_url` DESC") | |||
| ,Name_ASC("`name` ASC"),Name_DESC("`name` DESC") | |||
| ,LinkPhone_ASC("`linkPhone` ASC"),LinkPhone_DESC("`linkPhone` DESC") | |||
| ,BankCard_ASC("`bankCard` ASC"),BankCard_DESC("`bankCard` DESC") | |||
| ,BankName_ASC("`bankName` ASC"),BankName_DESC("`bankName` DESC") | |||
| ,PayId_ASC("`payId` ASC"),PayId_DESC("`payId` DESC") | |||
| ,CreateDate_ASC("`createDate` ASC"),CreateDate_DESC("`createDate` DESC") | |||
| ,UpdateDate_ASC("`updateDate` ASC"),UpdateDate_DESC("`updateDate` DESC") | |||
| ,CarVendorType_ASC("`carVendorType` ASC"),CarVendorType_DESC("`carVendorType` DESC") | |||
| ,CarParams_ASC("`carParams` ASC"),CarParams_DESC("`carParams` DESC") | |||
| ,LinkPhone_ASC("`link_phone` ASC"),LinkPhone_DESC("`link_phone` DESC") | |||
| ,CreateDate_ASC("`create_date` ASC"),CreateDate_DESC("`create_date` DESC") | |||
| ,UpdateDate_ASC("`update_date` ASC"),UpdateDate_DESC("`update_date` DESC") | |||
| ,CarVendorType_ASC("`car_vendor_type` ASC"),CarVendorType_DESC("`car_vendor_type` DESC") | |||
| ,CarParams_ASC("`car_params` ASC"),CarParams_DESC("`car_params` DESC") | |||
| ,Status_ASC("`status` ASC"),Status_DESC("`status` DESC") | |||
| ; | |||
| @@ -244,7 +247,8 @@ public class WxMerchant implements Serializable { | |||
| sb.append(","); | |||
| sb.append(fields[k].toString()); | |||
| } | |||
| this.sortColumns=sb.toString(); | |||
| } | |||
| public void setSortColumns(String sortColumns) | |||
| @@ -1,12 +1,11 @@ | |||
| package com.simple.domain.po; | |||
| import javax.persistence.*; | |||
| import java.util.*; | |||
| import java.math.*; | |||
| import javax.persistence.Transient; | |||
| import java.util.List; | |||
| import javax.persistence.Id; | |||
| import javax.persistence.Table; | |||
| import javax.persistence.Transient; | |||
| import java.io.Serializable; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| @Table(name = "wx_merchant_shop") | |||
| public class WxMerchantShop implements Serializable { | |||
| @@ -62,6 +61,10 @@ public class WxMerchantShop implements Serializable { | |||
| /*租期结束时间**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="租期结束时间",name="rentalEndDate") | |||
| private Date rentalEndDate; | |||
| @io.swagger.annotations.ApiModelProperty(value="删除状态",name="isDel") | |||
| private Integer isDel; | |||
| public String getTenantId() { | |||
| return tenantId; | |||
| } | |||
| @@ -105,7 +108,13 @@ public class WxMerchantShop implements Serializable { | |||
| rentalEndDate = _rentalEndDate; | |||
| } | |||
| public Integer getIsDel() { | |||
| return isDel; | |||
| } | |||
| public void setIsDel(Integer isDel) { | |||
| this.isDel = isDel; | |||
| } | |||
| public static enum Field | |||
| { | |||
| @@ -149,7 +158,9 @@ public class WxMerchantShop implements Serializable { | |||
| sb.append(","); | |||
| sb.append(fields[k].toString()); | |||
| } | |||
| this.sortColumns=sb.toString(); | |||
| } | |||
| public void setSortColumns(String sortColumns) | |||
| @@ -42,24 +42,40 @@ public class WxPayAccount implements Serializable { | |||
| /*微信商户号**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="微信商户号",name="mchId") | |||
| /**微信商户号/特约服务商号**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="微信商户号/特约服务商号",name="mchId") | |||
| private String mchId; | |||
| /*支付密钥**/ | |||
| /**微信服务商号*/ | |||
| @io.swagger.annotations.ApiModelProperty(value="微信服务商号",name="subMchId") | |||
| private String subMchId; | |||
| /**支付密钥**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="支付密钥",name="apiKey") | |||
| private String apiKey; | |||
| /*微信回调,支持3种回调,(1.url/pay 2.url/refund3.url/separate)**/ | |||
| /**微信回调,支持3种回调,(1.url/pay 2.url/refund3.url/separate)**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="微信回调,支持3种回调,(1.url/pay 2.url/refund3.url/separate)",name="notifyUrl") | |||
| private String notifyUrl; | |||
| /*证书本地存放位置**/ | |||
| /**证书本地存放位置**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="证书本地存放位置",name="certPath") | |||
| private String certPath; | |||
| /**商户模式**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="商户模式-0:普通商户模式1:服务商模式",name="type") | |||
| private Integer type; | |||
| public String getMchId() { | |||
| return mchId; | |||
| } | |||
| public void setMchId(String _mchId) { | |||
| mchId = _mchId; | |||
| } | |||
| public String getSubMchId() { | |||
| return subMchId; | |||
| } | |||
| public void setSubMchId(String subMchId) { | |||
| this.subMchId = subMchId; | |||
| } | |||
| public String getApiKey() { | |||
| return apiKey; | |||
| } | |||
| @@ -79,6 +95,14 @@ public class WxPayAccount implements Serializable { | |||
| certPath = _certPath; | |||
| } | |||
| public Integer getType() { | |||
| return type; | |||
| } | |||
| public void setType(Integer type) { | |||
| this.type = type; | |||
| } | |||
| public String getPayNotifyUrl() { | |||
| return notifyUrl + "/pay"; | |||
| } | |||
| @@ -92,11 +116,13 @@ public class WxPayAccount implements Serializable { | |||
| public static enum Field | |||
| { | |||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||
| ,MchId_ASC("`mch_id` ASC"),MchId_DESC("`mch_id` DESC") | |||
| ,ApiKey_ASC("`api_key` ASC"),ApiKey_DESC("`api_key` DESC") | |||
| ,NotifyUrl_ASC("`notify_url` ASC"),NotifyUrl_DESC("`notify_url` DESC") | |||
| ,CertPath_ASC("`cert_path` ASC"),CertPath_DESC("`cert_path` DESC") | |||
| ; | |||
| ,MchId_ASC("`mch_id` ASC"),MchId_DESC("`mch_id` DESC") | |||
| ,SubMchId_ASC("`sub_mch_id` ASC"),SubMchId_DESC("`sub_mch_id` DESC") | |||
| ,ApiKey_ASC("`api_key` ASC"),ApiKey_DESC("`api_key` DESC") | |||
| ,NotifyUrl_ASC("`notify_url` ASC"),NotifyUrl_DESC("`notify_url` DESC") | |||
| ,CertPath_ASC("`cert_path` ASC"),CertPath_DESC("`cert_path` DESC") | |||
| ,Type_ASC("`type` ASC"),Type_DESC("`type` DESC") | |||
| ; | |||
| private String value; | |||
| Field(String value){ | |||
| this.value = value; | |||
| @@ -69,6 +69,9 @@ public class WxPayOrder implements Serializable { | |||
| /*支付结束时间**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="支付结束时间",name="payTimeEnd") | |||
| private Date payTimeEnd; | |||
| /*微信预支付交易会话标识**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="微信预支付交易会话标识",name="prepayId") | |||
| private String prepayId; | |||
| /*微信生成的订单号**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="微信生成的订单号",name="transactionId") | |||
| private String transactionId; | |||
| @@ -138,6 +141,15 @@ public class WxPayOrder implements Serializable { | |||
| public void setPayTimeEnd(Date _payTimeEnd) { | |||
| payTimeEnd = _payTimeEnd; | |||
| } | |||
| public String getPrepayId() { | |||
| return prepayId; | |||
| } | |||
| public void setPrepayId(String prepayId) { | |||
| this.prepayId = prepayId; | |||
| } | |||
| public String getTransactionId() { | |||
| return transactionId; | |||
| } | |||
| @@ -174,20 +186,21 @@ public class WxPayOrder implements Serializable { | |||
| public static enum Field | |||
| { | |||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||
| ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") | |||
| ,CreateTime_ASC("`createTime` ASC"),CreateTime_DESC("`createTime` DESC") | |||
| ,UpdateTime_ASC("`updateTime` ASC"),UpdateTime_DESC("`updateTime` DESC") | |||
| ,OrderId_ASC("`orderId` ASC"),OrderId_DESC("`orderId` DESC") | |||
| ,CUserId_ASC("`cUserId` ASC"),CUserId_DESC("`cUserId` DESC") | |||
| ,TenantId_ASC("`tenant_id` ASC"),TenantId_DESC("`tenant_id` DESC") | |||
| ,CreateTime_ASC("`create_time` ASC"),CreateTime_DESC("`create_time` DESC") | |||
| ,UpdateTime_ASC("`update_time` ASC"),UpdateTime_DESC("`update_time` DESC") | |||
| ,OrderId_ASC("`order_id` ASC"),OrderId_DESC("`order_id` DESC") | |||
| ,CUserId_ASC("`c_user_id` ASC"),CUserId_DESC("`c_user_id` DESC") | |||
| ,Ip_ASC("`ip` ASC"),Ip_DESC("`ip` DESC") | |||
| ,PayAmount_ASC("`payAmount` ASC"),PayAmount_DESC("`payAmount` DESC") | |||
| ,PayTimeStart_ASC("`payTimeStart` ASC"),PayTimeStart_DESC("`payTimeStart` DESC") | |||
| ,PayTimeEnd_ASC("`payTimeEnd` ASC"),PayTimeEnd_DESC("`payTimeEnd` DESC") | |||
| ,TransactionId_ASC("`transactionId` ASC"),TransactionId_DESC("`transactionId` DESC") | |||
| ,PayVendor_ASC("`payVendor` ASC"),PayVendor_DESC("`payVendor` DESC") | |||
| ,PayOrderNo_ASC("`payOrderNo` ASC"),PayOrderNo_DESC("`payOrderNo` DESC") | |||
| ,PayOrderStatus_ASC("`payOrderStatus` ASC"),PayOrderStatus_DESC("`payOrderStatus` DESC") | |||
| ,FailReason_ASC("`failReason` ASC"),FailReason_DESC("`failReason` DESC") | |||
| ,PayAmount_ASC("`pay_amount` ASC"),PayAmount_DESC("`pay_amount` DESC") | |||
| ,PayTimeStart_ASC("`pay_time_start` ASC"),PayTimeStart_DESC("`pay_time_start` DESC") | |||
| ,PayTimeEnd_ASC("`pay_time_end` ASC"),PayTimeEnd_DESC("`pay_time_end` DESC") | |||
| ,PrepayId_ASC("`prepay_id` ASC"),PrepayId_DESC("`transaction_id` DESC") | |||
| ,TransactionId_ASC("`transaction_id` ASC"),TransactionId_DESC("`prepay_id` DESC") | |||
| ,PayVendor_ASC("`pay_vendor` ASC"),PayVendor_DESC("`pay_vendor` DESC") | |||
| ,PayOrderNo_ASC("`pay_order_no` ASC"),PayOrderNo_DESC("`pay_order_no` DESC") | |||
| ,PayOrderStatus_ASC("`pay_order_status` ASC"),PayOrderStatus_DESC("`pay_order_status` DESC") | |||
| ,FailReason_ASC("`fail_reason` ASC"),FailReason_DESC("`fail_reason` DESC") | |||
| ; | |||
| private String value; | |||
| Field(String value){ | |||
| @@ -220,6 +233,8 @@ public class WxPayOrder implements Serializable { | |||
| sb.append(","); | |||
| sb.append(fields[k].toString()); | |||
| } | |||
| this.sortColumns = sb.toString(); | |||
| } | |||
| @@ -47,10 +47,10 @@ public class WxProfitSharingOrder implements Serializable { | |||
| private String tenantId; | |||
| /*商户ID**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="商户ID",name="merchantId") | |||
| private String merchantId; | |||
| private Long merchantId; | |||
| /*订单ID**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="订单ID",name="orderId") | |||
| private String orderId; | |||
| private Long orderId; | |||
| /*分账总金额(分)**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="分账总金额(分)",name="payAmount") | |||
| private Integer payAmount; | |||
| @@ -65,7 +65,7 @@ public class WxProfitSharingOrder implements Serializable { | |||
| private String transactionId; | |||
| /*微信生成分账单号**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="微信生成分账单号",name="sharingOrderId") | |||
| private String sharingOrderId; | |||
| private String sharingOrderNo; | |||
| /*分账申请失败原因**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="分账申请失败原因",name="errorMsg") | |||
| private String errorMsg; | |||
| @@ -84,16 +84,16 @@ public class WxProfitSharingOrder implements Serializable { | |||
| public void setTenantId(String _tenantId) { | |||
| tenantId = _tenantId; | |||
| } | |||
| public String getMerchantId() { | |||
| public Long getMerchantId() { | |||
| return merchantId; | |||
| } | |||
| public void setMerchantId(String _merchantId) { | |||
| public void setMerchantId(Long _merchantId) { | |||
| merchantId = _merchantId; | |||
| } | |||
| public String getOrderId() { | |||
| public Long getOrderId() { | |||
| return orderId; | |||
| } | |||
| public void setOrderId(String _orderId) { | |||
| public void setOrderId(Long _orderId) { | |||
| orderId = _orderId; | |||
| } | |||
| public Integer getPayAmount() { | |||
| @@ -114,17 +114,17 @@ public class WxProfitSharingOrder implements Serializable { | |||
| public void setPayTimeStart(Date _payTimeStart) { | |||
| payTimeStart = _payTimeStart; | |||
| } | |||
| public String getTransactionId() { | |||
| public String getTransaction() { | |||
| return transactionId; | |||
| } | |||
| public void setTransactionId(String _transactionId) { | |||
| transactionId = _transactionId; | |||
| } | |||
| public String getSharingOrderId() { | |||
| return sharingOrderId; | |||
| public String getSharingOrderNo() { | |||
| return sharingOrderNo; | |||
| } | |||
| public void setSharingOrderId(String _sharingOrderId) { | |||
| sharingOrderId = _sharingOrderId; | |||
| public void setSharingOrderNo(String _sharingOrderNo) { | |||
| sharingOrderNo = _sharingOrderNo; | |||
| } | |||
| public String getErrorMsg() { | |||
| return errorMsg; | |||
| @@ -44,7 +44,7 @@ public class WxProfitSharingReceiver implements Serializable { | |||
| /*商户ID**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="商户ID",name="merchantId") | |||
| private String merchantId; | |||
| private Long merchantId; | |||
| /*分账接收方类型,1 = MERCHANT_ID(商户 ID) 2 = PERSONAL_WECHATID(个人微信号) 3 = PERSONAL_OPENID(个人openid(由父商 户 APPID 转换得到) 4 = PERSONAL_SUB_OPENID(个人 sub_openid(由子商户 APPID 转换得到))**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="分账接收方类型,1 = MERCHANT_ID(商户 ID) 2 = PERSONAL_WECHATID(个人微信号) 3 = PERSONAL_OPENID(个人openid(由父商 户 APPID 转换得到) 4 = PERSONAL_SUB_OPENID(个人 sub_openid(由子商户 APPID 转换得到))",name="receiverType") | |||
| private Integer receiverType; | |||
| @@ -72,10 +72,10 @@ public class WxProfitSharingReceiver implements Serializable { | |||
| /***/ | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="bankCode") | |||
| private String bankCode; | |||
| public String getMerchantId() { | |||
| public Long getMerchantId() { | |||
| return merchantId; | |||
| } | |||
| public void setMerchantId(String _merchantId) { | |||
| public void setMerchantId(Long _merchantId) { | |||
| merchantId = _merchantId; | |||
| } | |||
| public Integer getReceiverType() { | |||
| @@ -44,10 +44,10 @@ public class WxProfitSharingResult implements Serializable { | |||
| /*分账订单号**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="分账订单号",name="sharingOrderId") | |||
| private String sharingOrderId; | |||
| private Long sharingOrderId; | |||
| /*分账接收方id**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="分账接收方id",name="sharingReceiverId") | |||
| private String sharingReceiverId; | |||
| private Long sharingReceiverId; | |||
| /*分账金额(分)**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="分账金额(分)",name="payAmount") | |||
| private Integer payAmount; | |||
| @@ -66,16 +66,16 @@ public class WxProfitSharingResult implements Serializable { | |||
| /*微信返回的失败原因**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="微信返回的失败原因",name="failedReason") | |||
| private String failedReason; | |||
| public String getSharingOrderId() { | |||
| public Long getSharingOrderId() { | |||
| return sharingOrderId; | |||
| } | |||
| public void setSharingOrderId(String _sharingOrderId) { | |||
| public void setSharingOrderId(Long _sharingOrderId) { | |||
| sharingOrderId = _sharingOrderId; | |||
| } | |||
| public String getSharingReceiverId() { | |||
| public Long getSharingReceiverId() { | |||
| return sharingReceiverId; | |||
| } | |||
| public void setSharingReceiverId(String _sharingReceiverId) { | |||
| public void setSharingReceiverId(Long _sharingReceiverId) { | |||
| sharingReceiverId = _sharingReceiverId; | |||
| } | |||
| public Integer getPayAmount() { | |||
| @@ -239,7 +239,7 @@ public class WxShop implements Serializable { | |||
| sb.append(","); | |||
| sb.append(fields[k].toString()); | |||
| } | |||
| this.sortColumns=sb.toString(); | |||
| } | |||
| public void setSortColumns(String sortColumns) | |||
| @@ -0,0 +1,152 @@ | |||
| package com.simple.domain.po; | |||
| import javax.persistence.*; | |||
| import java.util.*; | |||
| import java.math.*; | |||
| import javax.persistence.Transient; | |||
| import java.util.List; | |||
| import javax.persistence.Id; | |||
| import java.io.Serializable; | |||
| @Table(name = "wx_template_msg") | |||
| public class WxTemplateMsg implements Serializable { | |||
| private static final long serialVersionUID = 1L; | |||
| @Id | |||
| protected Long id; | |||
| @Transient | |||
| protected List<Long> ids; | |||
| @Transient | |||
| protected String sortColumns; | |||
| public Long getId() { | |||
| return id; | |||
| } | |||
| public void setId(Long id) { | |||
| this.id = id; | |||
| } | |||
| public String getSortColumns() { | |||
| return sortColumns; | |||
| } | |||
| public List<Long> getIds() { | |||
| return ids; | |||
| } | |||
| public void setIds(List<Long> ids) { | |||
| this.ids = ids; | |||
| } | |||
| /*租户ID**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") | |||
| private String tenantId; | |||
| /*模板ID**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="模板ID",name="templateId") | |||
| private String templateId; | |||
| /*模板类型1:支付成功消息2:退款申请成功消息**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="模板类型1:支付成功消息2:退款申请成功消息",name="type") | |||
| private Integer type; | |||
| /*创建时间**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | |||
| private Date createDate; | |||
| /*更新时间**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | |||
| private Date updateDate; | |||
| public String getTenantId() { | |||
| return tenantId; | |||
| } | |||
| public void setTenantId(String _tenantId) { | |||
| tenantId = _tenantId; | |||
| } | |||
| public String getTemplateId() { | |||
| return templateId; | |||
| } | |||
| public void setTemplateId(String _templateId) { | |||
| templateId = _templateId; | |||
| } | |||
| public Integer getType() { | |||
| return type; | |||
| } | |||
| public void setType(Integer _type) { | |||
| type = _type; | |||
| } | |||
| public Date getCreateDate() { | |||
| return createDate; | |||
| } | |||
| public void setCreateDate(Date _createDate) { | |||
| createDate = _createDate; | |||
| } | |||
| public Date getUpdateDate() { | |||
| return updateDate; | |||
| } | |||
| public void setUpdateDate(Date _updateDate) { | |||
| updateDate = _updateDate; | |||
| } | |||
| public static enum Field | |||
| { | |||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||
| ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") | |||
| ,TemplateId_ASC("`templateId` ASC"),TemplateId_DESC("`templateId` DESC") | |||
| ,Type_ASC("`type` ASC"),Type_DESC("`type` DESC") | |||
| ,CreateDate_ASC("`createDate` ASC"),CreateDate_DESC("`createDate` DESC") | |||
| ,UpdateDate_ASC("`updateDate` ASC"),UpdateDate_DESC("`updateDate` DESC") | |||
| ; | |||
| private String value; | |||
| Field(String value){ | |||
| this.value = value; | |||
| } | |||
| public String getValue() { | |||
| return value; | |||
| } | |||
| public void setCol(String value) { | |||
| this.value = value; | |||
| } | |||
| @Override | |||
| public String toString() { | |||
| return this.getValue(); | |||
| } | |||
| } | |||
| public void setSortColumns(WxTemplateMsg.Field... fields) | |||
| { | |||
| if (fields == null || fields.length == 0) { | |||
| return; | |||
| } | |||
| for (int k = 0; k < fields.length; k++) { | |||
| if (fields[k] == null) { | |||
| return; | |||
| } | |||
| } | |||
| StringBuilder sb = new StringBuilder(fields[0].toString()); | |||
| for (int k = 1; k < fields.length; k++) { | |||
| sb.append(","); | |||
| sb.append(fields[k].toString()); | |||
| } | |||
| } | |||
| public void setSortColumns(String sortColumns) | |||
| { | |||
| if (sortColumns == null || "".equals(sortColumns.trim())) { | |||
| return; | |||
| } | |||
| if (sortColumns.contains(",")) { | |||
| String[] cols = sortColumns.split(","); | |||
| java.util.List<Field> fList = new java.util.ArrayList(); | |||
| for (int k = 0; k < cols.length; k++) { | |||
| fList.add(Field.valueOf(cols[k])); | |||
| } | |||
| this.setSortColumns(fList.toArray(new Field[fList.size()])); | |||
| } else { | |||
| this.setSortColumns(Field.valueOf(sortColumns)); | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,96 @@ | |||
| package com.simple.domain.vo; | |||
| import com.simple.domain.po.WxCouponOrder; | |||
| import javax.persistence.Id; | |||
| import javax.persistence.Transient; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| public class WxCouponOrderCarCVo extends WxCouponOrderCVo { | |||
| /** | |||
| * | |||
| */ | |||
| private static final long serialVersionUID = 6687954932922444531L; | |||
| /*couponFreeId**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="couponFreeId",name="couponFreeId") | |||
| private Integer couponFreeId; | |||
| public Integer getCouponFreeId() { | |||
| return couponFreeId; | |||
| } | |||
| public void setCouponFreeId(Integer couponFreeId) { | |||
| this.couponFreeId = couponFreeId; | |||
| } | |||
| public static enum Field { | |||
| Id_ASC("`id` ASC"), Id_DESC("`id` DESC"), | |||
| TenantId_ASC("`tenant_id` ASC"), TenantId_DESC("`tenant_id` DESC"), | |||
| CouponId_ASC("`coupon_id` ASC"), couponId_DESC("`coupon_id` DESC"), | |||
| CUserId_ASC("`c_user_id` ASC"), CUserId_DESC("`c_user_id` DESC"), | |||
| BUserId_ASC("`b_user_id` ASC"), BUserId_DESC("`b_user_id` DESC"), | |||
| OrderId_ASC("`order_id` ASC"), OrderId_DESC("`order_id` DESC"), | |||
| ExpiredTime_ASC("`expired_iime` ASC"), ExpiredTime_DESC("`expired_iime` DESC"), | |||
| CouponOrderStatus_ASC("`coupon_order_status` ASC"), CouponOrderStatus_DESC("`coupon_order_status` DESC"), | |||
| CreateDate_ASC("`create_date` ASC"), CreateDate_DESC("`create_date` DESC"), | |||
| UpdateDate_ASC("`update_date` ASC"), UpdateDate_DESC("`update_date` DESC"), | |||
| CouponPrice_ASC("`coupon_price` ASC"), CouponPrice_DESC("`coupon_price` DESC"), | |||
| CouponFreeId_ASC("`coupon_free_id` ASC"), CouponFreeId_DESC("`coupon_free_id` DESC"); | |||
| private String value; | |||
| Field(String value) { | |||
| this.value = value; | |||
| } | |||
| public String getValue() { | |||
| return value; | |||
| } | |||
| public void setCol(String value) { | |||
| this.value = value; | |||
| } | |||
| @Override | |||
| public String toString() { | |||
| return this.getValue(); | |||
| } | |||
| } | |||
| public void setSortColumns(WxCouponOrder.Field... fields) { | |||
| if (fields == null || fields.length == 0) { | |||
| return; | |||
| } | |||
| for (int k = 0; k < fields.length; k++) { | |||
| if (fields[k] == null) { | |||
| return; | |||
| } | |||
| } | |||
| StringBuilder sb = new StringBuilder(fields[0].toString()); | |||
| for (int k = 1; k < fields.length; k++) { | |||
| sb.append(","); | |||
| sb.append(fields[k].toString()); | |||
| } | |||
| this.sortColumns = sb.toString(); | |||
| } | |||
| public void setSortColumns(String sortColumns) { | |||
| if (sortColumns == null || "".equals(sortColumns.trim())) { | |||
| return; | |||
| } | |||
| if (sortColumns.contains(",")) { | |||
| String[] cols = sortColumns.split(","); | |||
| List<WxCouponOrder.Field> fList = new java.util.ArrayList(); | |||
| for (int k = 0; k < cols.length; k++) { | |||
| fList.add(WxCouponOrder.Field.valueOf(cols[k])); | |||
| } | |||
| this.setSortColumns(fList.toArray(new WxCouponOrder.Field[fList.size()])); | |||
| } else { | |||
| this.setSortColumns(WxCouponOrder.Field.valueOf(sortColumns)); | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,37 @@ | |||
| package com.simple.enums; | |||
| /** | |||
| * Created by Stormeye on 2018/08/09. | |||
| */ | |||
| public enum EnumCouponSendType { | |||
| // 2:停车发券 3:核销发券 | |||
| CAR_STOP(2, "停车发券"), | |||
| COUPON_VERIFY(3, "核销发券") | |||
| ; | |||
| public static EnumCouponSendType getEnum(Integer code) { | |||
| for (EnumCouponSendType value : values()) { | |||
| if (value.getCode().equals(code)) { | |||
| return value; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| private Integer code; | |||
| private String message; | |||
| EnumCouponSendType(Integer code, String message) { | |||
| this.code = code; | |||
| this.message = message; | |||
| } | |||
| public Integer getCode() { | |||
| return code; | |||
| } | |||
| public String getMessage() { | |||
| return message; | |||
| } | |||
| } | |||
| @@ -0,0 +1,35 @@ | |||
| package com.simple.enums; | |||
| /** | |||
| * Created by Stormeye on 2018/08/09. | |||
| */ | |||
| public enum EnumPayMode { | |||
| MCH(0, "普通商户模式"), | |||
| MCH_S(1, "服务商模式"); | |||
| public static EnumPayMode getEnum(Integer code) { | |||
| for (EnumPayMode value : values()) { | |||
| if (value.getCode().equals(code)) { | |||
| return value; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| private Integer code; | |||
| private String message; | |||
| EnumPayMode(Integer code, String message) { | |||
| this.code = code; | |||
| this.message = message; | |||
| } | |||
| public Integer getCode() { | |||
| return code; | |||
| } | |||
| public String getMessage() { | |||
| return message; | |||
| } | |||
| } | |||
| @@ -0,0 +1,35 @@ | |||
| package com.simple.enums; | |||
| /** | |||
| * Created by Stormeye on 2018/08/09. | |||
| */ | |||
| public enum EnumProfitSharingType { | |||
| PROFIT_SHARING_TYPE_WECHAT(1, "MERCHANT_ID"), | |||
| PROFIT_SHARING_TYPE_BANK(2, "PERSONAL_WECHATID"), | |||
| ; | |||
| public static EnumProfitSharingType getEnum(Integer code) { | |||
| for (EnumProfitSharingType value : values()) { | |||
| if (value.getCode().equals(code)) { | |||
| return value; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| private Integer code; | |||
| private String message; | |||
| EnumProfitSharingType(Integer code, String message) { | |||
| this.code = code; | |||
| this.message = message; | |||
| } | |||
| public Integer getCode() { | |||
| return code; | |||
| } | |||
| public String getMessage() { | |||
| return message; | |||
| } | |||
| } | |||
| @@ -0,0 +1,37 @@ | |||
| package com.simple.enums; | |||
| /** | |||
| * Created by Stormeye on 2018/08/09. | |||
| */ | |||
| public enum EnumRefundWay { | |||
| B(0, "B端小程序"), | |||
| ADMIN(1, "WEB端小程序"), | |||
| C(2, "C端小程序"), | |||
| AUTO(3, "自动退款"); | |||
| public static EnumRefundWay getEnum(Integer code) { | |||
| for (EnumRefundWay value : values()) { | |||
| if (value.getCode().equals(code)) { | |||
| return value; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| private Integer code; | |||
| private String message; | |||
| EnumRefundWay(Integer code, String message) { | |||
| this.code = code; | |||
| this.message = message; | |||
| } | |||
| public Integer getCode() { | |||
| return code; | |||
| } | |||
| public String getMessage() { | |||
| return message; | |||
| } | |||
| } | |||
| @@ -0,0 +1,39 @@ | |||
| package com.simple.enums; | |||
| /** | |||
| * Created by Stormeye on 2018/08/09. | |||
| */ | |||
| public enum EnumTemplateType { | |||
| // 1-支付成功消息, 2-支付失败消息 3-退款消息 | |||
| PAY_SUCCESS(1, "订单支付成功通知"), | |||
| PAY_FAIL(2, "支付失败通知"), | |||
| REFUND(3, "退款通知") | |||
| ; | |||
| public static EnumTemplateType getEnum(Integer code) { | |||
| for (EnumTemplateType value : values()) { | |||
| if (value.getCode().equals(code)) { | |||
| return value; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| private Integer code; | |||
| private String message; | |||
| EnumTemplateType(Integer code, String message) { | |||
| this.code = code; | |||
| this.message = message; | |||
| } | |||
| public Integer getCode() { | |||
| return code; | |||
| } | |||
| public String getMessage() { | |||
| return message; | |||
| } | |||
| } | |||
| @@ -17,6 +17,8 @@ public interface WxCouponChannelMapper extends CommonMapper<WxCouponChannel, Str | |||
| void offExpiriedCouponChannelByEndTime(); | |||
| void offExpiriedCouponChannelByValidDate(); | |||
| void offExpiriedCouponChannelByCouponStatus(); | |||
| } | |||
| @@ -23,9 +23,11 @@ public interface WxCouponOrderMapper extends CommonMapper<WxCouponOrder, Long> { | |||
| WxCouponOrderCVo selectDetailOfUser(Map paramMap); | |||
| List<WxCouponOrderCVo> findListOfCUser(WxCouponOrder wxCouponOrder); | |||
| List<WxCouponOrderCVo> findListOfCUser(WxCouponOrderCVo wxCouponOrder); | |||
| List<WxCouponOrderBVo> findListOfAdmin(WxCouponOrder wxCouponOrder); | |||
| List<WxCouponOrderCarCVo> findCarListOfCUser(WxCouponOrderCarCVo wxCouponOrder); | |||
| //营销报表 券数据图表 | |||
| List<MarkingCouponDataReportVo> couponDataMap(HashMap<String,Object> params); | |||
| @@ -62,4 +64,7 @@ public interface WxCouponOrderMapper extends CommonMapper<WxCouponOrder, Long> { | |||
| int queryPriceTotal(@Param("tenantId")String tenantId, @Param("startTime") Date startTime, @Param("endTime")Date endTime); | |||
| void offExpiredCouponOrderByValidDate(); | |||
| List<WxCouponOrder> findExpiredCouponOrderByValidDate(); | |||
| } | |||
| @@ -0,0 +1,17 @@ | |||
| package com.simple.mapper; | |||
| import com.simple.common.CommonMapper; | |||
| import com.simple.domain.po.WxMallApply; | |||
| import java.util.List; | |||
| public interface WxMallApplyMapper extends CommonMapper<WxMallApply, String> { | |||
| List<WxMallApply> findList(WxMallApply wxMallApply); | |||
| } | |||
| @@ -8,10 +8,4 @@ import com.simple.domain.po.WxPayOrder; | |||
| public interface WxPayOrderMapper extends CommonMapper<WxPayOrder, Long> { | |||
| List<WxPayOrder> findList(WxPayOrder wxPayOrder); | |||
| } | |||
| @@ -0,0 +1,17 @@ | |||
| package com.simple.mapper; | |||
| import java.util.*; | |||
| import com.simple.common.CommonMapper; | |||
| import org.apache.ibatis.annotations.Param; | |||
| import com.simple.domain.po.WxTemplateMsg; | |||
| public interface WxTemplateMsgMapper extends CommonMapper<WxTemplateMsg, Long> { | |||
| List<WxTemplateMsg> findList(WxTemplateMsg wxTemplateMsg); | |||
| } | |||
| @@ -2,9 +2,10 @@ package com.simple.pay; | |||
| /** | |||
| * Created by Stormeye on 2018/8/10. | |||
| * 普通商户模式 | |||
| */ | |||
| public class WxPayOrderP { | |||
| private String appid; // 公众账号ID | |||
| private String appid; // 小程序ID | |||
| private String mch_id; // 商户号 | |||
| private String nonce_str; // 随机字符串 | |||
| private String sign; // 签名 | |||
| @@ -4,7 +4,7 @@ package com.simple.pay; | |||
| * Created by Stormeye on 2018/8/10. | |||
| */ | |||
| public class WxPayOrderQ { | |||
| private String appid; // 公众账号ID | |||
| private String appid; // 小程序ID | |||
| private String mch_id; // 商户号 | |||
| private String nonce_str; // 随机字符串 | |||
| private String sign; // 签名 | |||
| @@ -0,0 +1,175 @@ | |||
| package com.simple.pay; | |||
| /** | |||
| * Created by Stormeye on 2018/8/10. | |||
| * 服务商模式 | |||
| */ | |||
| public class WxPayOrderSP { | |||
| private String appid; // 公众账号ID | |||
| private String sub_appid; // 小程序ID | |||
| private String mch_id; // 服务商号 | |||
| private String sub_mch_id; // 特约商户号 | |||
| private String nonce_str; // 随机字符串 | |||
| private String sign; // 签名 | |||
| private String body; // 商品简单描述 128 | |||
| private String out_trade_no; // 商户订单号 | |||
| private Integer total_fee; // 支付金额 | |||
| private String spbill_create_ip; // 支付IP | |||
| private String notify_url; // 通知地址 | |||
| private String trade_type; // 支付类型 | |||
| private String product_id; // 商品ID - 扫码必传 | |||
| private String time_start; // 开始时间 | |||
| private String time_expire; // 失效时间 | |||
| private String sub_openid; // sub_openId | |||
| public String getTime_start() { | |||
| return time_start; | |||
| } | |||
| public void setTime_start(String time_start) { | |||
| this.time_start = time_start; | |||
| } | |||
| public String getTime_expire() { | |||
| return time_expire; | |||
| } | |||
| public void setTime_expire(String time_expire) { | |||
| this.time_expire = time_expire; | |||
| } | |||
| public String getAppid() { | |||
| return appid; | |||
| } | |||
| public void setAppid(String appid) { | |||
| this.appid = appid; | |||
| } | |||
| public String getSub_appid() { | |||
| return sub_appid; | |||
| } | |||
| public void setSub_appid(String sub_appid) { | |||
| this.sub_appid = sub_appid; | |||
| } | |||
| public String getMch_id() { | |||
| return mch_id; | |||
| } | |||
| public void setMch_id(String mch_id) { | |||
| this.mch_id = mch_id; | |||
| } | |||
| public String getSub_mch_id() { | |||
| return sub_mch_id; | |||
| } | |||
| public void setSub_mch_id(String sub_mch_id) { | |||
| this.sub_mch_id = sub_mch_id; | |||
| } | |||
| public String getNonce_str() { | |||
| return nonce_str; | |||
| } | |||
| public void setNonce_str(String nonce_str) { | |||
| this.nonce_str = nonce_str; | |||
| } | |||
| public String getSign() { | |||
| return sign; | |||
| } | |||
| public void setSign(String sign) { | |||
| this.sign = sign; | |||
| } | |||
| public String getBody() { | |||
| return body; | |||
| } | |||
| public void setBody(String body) { | |||
| this.body = body; | |||
| } | |||
| public String getOut_trade_no() { | |||
| return out_trade_no; | |||
| } | |||
| public void setOut_trade_no(String out_trade_no) { | |||
| this.out_trade_no = out_trade_no; | |||
| } | |||
| public Integer getTotal_fee() { | |||
| return total_fee; | |||
| } | |||
| public void setTotal_fee(Integer total_fee) { | |||
| this.total_fee = total_fee; | |||
| } | |||
| public String getSpbill_create_ip() { | |||
| return spbill_create_ip; | |||
| } | |||
| public void setSpbill_create_ip(String spbill_create_ip) { | |||
| this.spbill_create_ip = spbill_create_ip; | |||
| } | |||
| public String getNotify_url() { | |||
| return notify_url; | |||
| } | |||
| public void setNotify_url(String notify_url) { | |||
| this.notify_url = notify_url; | |||
| } | |||
| public String getTrade_type() { | |||
| return trade_type; | |||
| } | |||
| public void setTrade_type(String trade_type) { | |||
| this.trade_type = trade_type; | |||
| } | |||
| public String getProduct_id() { | |||
| return product_id; | |||
| } | |||
| public void setProduct_id(String product_id) { | |||
| this.product_id = product_id; | |||
| } | |||
| public String getSub_openid() { | |||
| return sub_openid; | |||
| } | |||
| public void setSub_openid(String sub_openid) { | |||
| this.sub_openid = sub_openid; | |||
| } | |||
| @Override | |||
| public String toString() { | |||
| final StringBuilder sb = new StringBuilder("WxPayOrder{"); | |||
| sb.append("appid='").append(appid).append('\''); | |||
| sb.append("sub_appid='").append(sub_appid).append('\''); | |||
| sb.append(", mch_id='").append(mch_id).append('\''); | |||
| sb.append(", sub_mch_id='").append(sub_mch_id).append('\''); | |||
| sb.append(", nonce_str='").append(nonce_str).append('\''); | |||
| sb.append(", sign='").append(sign).append('\''); | |||
| sb.append(", body='").append(body).append('\''); | |||
| sb.append(", out_trade_no='").append(out_trade_no).append('\''); | |||
| sb.append(", total_fee=").append(total_fee); | |||
| sb.append(", spbill_create_ip='").append(spbill_create_ip).append('\''); | |||
| sb.append(", notify_url='").append(notify_url).append('\''); | |||
| sb.append(", trade_type='").append(trade_type).append('\''); | |||
| sb.append(", product_id='").append(product_id).append('\''); | |||
| sb.append(", time_start='").append(time_start).append('\''); | |||
| sb.append(", time_expire='").append(time_expire).append('\''); | |||
| sb.append(", sub_openid='").append(sub_openid).append('\''); | |||
| sb.append('}'); | |||
| return sb.toString(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,85 @@ | |||
| package com.simple.pay; | |||
| /** | |||
| * Created by Stormeye on 2018/8/10. | |||
| */ | |||
| public class WxPayOrderSQ { | |||
| private String appid; // 公众号ID | |||
| private String sub_appid; // 小程序ID | |||
| private String mch_id; // 服务号 | |||
| private String sub_mch_id; // 特约商户号 | |||
| private String nonce_str; // 随机字符串 | |||
| private String sign; // 签名 | |||
| private String out_trade_no; // 商户订单号 | |||
| public String getAppid() { | |||
| return appid; | |||
| } | |||
| public void setAppid(String appid) { | |||
| this.appid = appid; | |||
| } | |||
| public String getSub_appid() { | |||
| return sub_appid; | |||
| } | |||
| public void setSub_appid(String sub_appid) { | |||
| this.sub_appid = sub_appid; | |||
| } | |||
| public String getMch_id() { | |||
| return mch_id; | |||
| } | |||
| public void setMch_id(String mch_id) { | |||
| this.mch_id = mch_id; | |||
| } | |||
| public String getSub_mch_id() { | |||
| return sub_mch_id; | |||
| } | |||
| public void setSub_mch_id(String sub_mch_id) { | |||
| this.sub_mch_id = sub_mch_id; | |||
| } | |||
| public String getNonce_str() { | |||
| return nonce_str; | |||
| } | |||
| public void setNonce_str(String nonce_str) { | |||
| this.nonce_str = nonce_str; | |||
| } | |||
| public String getSign() { | |||
| return sign; | |||
| } | |||
| public void setSign(String sign) { | |||
| this.sign = sign; | |||
| } | |||
| public String getOut_trade_no() { | |||
| return out_trade_no; | |||
| } | |||
| public void setOut_trade_no(String out_trade_no) { | |||
| this.out_trade_no = out_trade_no; | |||
| } | |||
| @Override | |||
| public String toString() { | |||
| final StringBuilder sb = new StringBuilder("WxPayOrder{"); | |||
| sb.append("appid='").append(appid).append('\''); | |||
| sb.append("sub_appid='").append(sub_appid).append('\''); | |||
| sb.append(", mch_id='").append(mch_id).append('\''); | |||
| sb.append(", sub_mch_id='").append(sub_mch_id).append('\''); | |||
| sb.append(", nonce_str='").append(nonce_str).append('\''); | |||
| sb.append(", sign='").append(sign).append('\''); | |||
| sb.append(", out_trade_no='").append(out_trade_no).append('\''); | |||
| sb.append('}'); | |||
| return sb.toString(); | |||
| } | |||
| } | |||
| @@ -289,6 +289,37 @@ public class WxPayment { | |||
| return buildSignAfterParasMap(params, paternerKey); | |||
| } | |||
| /** | |||
| * 服务商查询退款 | |||
| * | |||
| * @param appid | |||
| * @param mch_id | |||
| * @param out_trade_no | |||
| * @param paternerKey | |||
| * @return | |||
| */ | |||
| public static Map<String, String> buildSWeappRefundQueryMap(String appid, String sub_appid, String mch_id, String sub_mch_id, | |||
| String transaction_id, String out_trade_no, String out_refund_no, String refund_id, | |||
| String paternerKey) { | |||
| Map<String, String> params = new HashMap<String, String>(); | |||
| params.put("appid", appid); | |||
| params.put("sub_appid", sub_appid); | |||
| params.put("mch_id", mch_id); | |||
| params.put("sub_mch_id", sub_mch_id); | |||
| if(!StringUtils.isBlank(refund_id)) { | |||
| params.put("refund_id", refund_id); | |||
| } else if (!StringUtils.isBlank(out_refund_no)) { | |||
| params.put("out_refund_no", out_refund_no); | |||
| } else if (!StringUtils.isBlank(transaction_id)) { | |||
| params.put("transaction_id", transaction_id); | |||
| } else if (!StringUtils.isBlank(out_trade_no)) { | |||
| params.put("out_trade_no", out_trade_no); | |||
| } | |||
| return buildSignAfterParasMap(params, paternerKey); | |||
| } | |||
| /** | |||
| * 组装签名的字段 | |||
| * | |||
| @@ -42,6 +42,20 @@ public class WxProfitSharing { | |||
| } | |||
| /** | |||
| * 分账接收方添加 | |||
| * @param params | |||
| * @return | |||
| */ | |||
| public static String addReceiver(Map<String, String> params) {return doPost(RPOFIT_SHARING_ADD_RECEIVER_URL, params); } | |||
| /** | |||
| * 分账接收方删除 | |||
| * @param params | |||
| * @return | |||
| */ | |||
| public static String delReceiver(Map<String, String> params) {return doPost(RPOFIT_SHARING_REMOVE_RECEIVER_URL, params); } | |||
| public static String doPost(String url, Map<String, String> params) { | |||
| return HttpUtil.payPost(url, WxPayment.toXml(params)); | |||
| } | |||
| @@ -0,0 +1,73 @@ | |||
| package com.simple.pay; | |||
| import java.io.Serializable; | |||
| /** | |||
| * Created by Peng on 2018/8/10. | |||
| */ | |||
| public class WxProfitSharingReceiverP implements Serializable { | |||
| private static final long serialVersionUID = 1L; | |||
| private String mch_id; // 商户号 | |||
| private String sub_mch_id; // 子商户号 | |||
| private String appid; // 公众账号ID | |||
| private String sub_appid; // 子公众账号ID | |||
| private String nonce_str; // 随机字符串 | |||
| private String sign; // 签名 | |||
| private String receiver; // 分账接收方 | |||
| public String getMch_id() { | |||
| return mch_id; | |||
| } | |||
| public void setMch_id(String mch_id) { | |||
| this.mch_id = mch_id; | |||
| } | |||
| public String getSub_mch_id() { return sub_mch_id; } | |||
| public void setSub_mch_id(String sub_mch_id) { | |||
| this.sub_mch_id = sub_mch_id; | |||
| } | |||
| public String getAppid() { | |||
| return appid; | |||
| } | |||
| public void setAppid(String appid) { | |||
| this.appid = appid; | |||
| } | |||
| public String getSub_appid() { | |||
| return sub_appid; | |||
| } | |||
| public void setSub_appid(String sub_appid) { | |||
| this.sub_appid = sub_appid; | |||
| } | |||
| public String getNonce_str() { | |||
| return nonce_str; | |||
| } | |||
| public void setNonce_str(String nonce_str) { | |||
| this.nonce_str = nonce_str; | |||
| } | |||
| public String getSign() { | |||
| return sign; | |||
| } | |||
| public void setSign(String sign) { | |||
| this.sign = sign; | |||
| } | |||
| public String getReceiver() { | |||
| return receiver; | |||
| } | |||
| public void setReceiver(String receiver) { | |||
| this.receiver = receiver; | |||
| } | |||
| } | |||
| @@ -4,7 +4,7 @@ package com.simple.pay; | |||
| * Created by Stormeye on 2018/8/10. | |||
| */ | |||
| public class WxRefundOrderP { | |||
| private String appid; // 公众账号ID | |||
| private String appid; // 小程序ID | |||
| private String mch_id; // 商户号 | |||
| private String nonce_str; // 随机字符串 | |||
| private String sign; // 签名 | |||
| @@ -0,0 +1,139 @@ | |||
| package com.simple.pay; | |||
| /** | |||
| * Created by Stormeye on 2018/8/10. | |||
| */ | |||
| public class WxRefundOrderSP { | |||
| private String appid; // 公众账号ID | |||
| private String sub_appid; // 小程序ID | |||
| private String mch_id; // 服务号 | |||
| private String sub_mch_id; // 特约商户号 | |||
| private String nonce_str; // 随机字符串 | |||
| private String sign; // 签名 | |||
| private String transaction_id; // 微信订单号 | |||
| private String out_trade_no; // 商户订单号 | |||
| private String out_refund_no; // 商户退款单号 | |||
| private Integer total_fee; // 支付金额 | |||
| private Integer refund_fee; // 退款金额 | |||
| private String refund_desc; // 退款原因 | |||
| private String notify_url; // 回调接口 | |||
| public String getAppid() { | |||
| return appid; | |||
| } | |||
| public void setAppid(String appid) { | |||
| this.appid = appid; | |||
| } | |||
| public String getSub_appid() { | |||
| return sub_appid; | |||
| } | |||
| public void setSub_appid(String sub_appid) { | |||
| this.sub_appid = sub_appid; | |||
| } | |||
| public String getMch_id() { | |||
| return mch_id; | |||
| } | |||
| public void setMch_id(String mch_id) { | |||
| this.mch_id = mch_id; | |||
| } | |||
| public String getSub_mch_id() { | |||
| return sub_mch_id; | |||
| } | |||
| public void setSub_mch_id(String sub_mch_id) { | |||
| this.sub_mch_id = sub_mch_id; | |||
| } | |||
| public String getNonce_str() { | |||
| return nonce_str; | |||
| } | |||
| public void setNonce_str(String nonce_str) { | |||
| this.nonce_str = nonce_str; | |||
| } | |||
| public String getSign() { | |||
| return sign; | |||
| } | |||
| public void setSign(String sign) { | |||
| this.sign = sign; | |||
| } | |||
| public String getTransaction_id() { | |||
| return transaction_id; | |||
| } | |||
| public void setTransaction_id(String transaction_id) { | |||
| this.transaction_id = transaction_id; | |||
| } | |||
| public String getOut_trade_no() { | |||
| return out_trade_no; | |||
| } | |||
| public void setOut_trade_no(String out_trade_no) { | |||
| this.out_trade_no = out_trade_no; | |||
| } | |||
| public String getOut_refund_no() { | |||
| return out_refund_no; | |||
| } | |||
| public void setOut_refund_no(String out_refund_no) { | |||
| this.out_refund_no = out_refund_no; | |||
| } | |||
| public Integer getTotal_fee() { | |||
| return total_fee; | |||
| } | |||
| public void setTotal_fee(Integer total_fee) { | |||
| this.total_fee = total_fee; | |||
| } | |||
| public Integer getRefund_fee() { | |||
| return refund_fee; | |||
| } | |||
| public void setRefund_fee(Integer refund_fee) { | |||
| this.refund_fee = refund_fee; | |||
| } | |||
| public String getRefund_desc() { | |||
| return refund_desc; | |||
| } | |||
| public void setRefund_desc(String refund_desc) { | |||
| this.refund_desc = refund_desc; | |||
| } | |||
| public String getNotify_url() { | |||
| return notify_url; | |||
| } | |||
| public void setNotify_url(String notify_url) { | |||
| this.notify_url = notify_url; | |||
| } | |||
| @Override | |||
| public String toString() { | |||
| final StringBuilder sb = new StringBuilder("WxRefundOrder{"); | |||
| sb.append("appid='").append(appid).append('\''); | |||
| sb.append(", mch_id='").append(mch_id).append('\''); | |||
| sb.append(", nonce_str='").append(nonce_str).append('\''); | |||
| sb.append(", sign='").append(sign).append('\''); | |||
| sb.append(", out_trade_no='").append(out_trade_no).append('\''); | |||
| sb.append(", out_refund_no='").append(out_refund_no).append('\''); | |||
| sb.append(", total_fee=").append(total_fee); | |||
| sb.append(", refund_fee=").append(refund_fee); | |||
| sb.append('}'); | |||
| return sb.toString(); | |||
| } | |||
| } | |||
| @@ -11,6 +11,8 @@ import java.util.List; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import com.simple.domain.vo.WxCouponOrderCVo; | |||
| import com.simple.domain.vo.WxCouponOrderCarCVo; | |||
| import org.apache.ibatis.annotations.Param; | |||
| public interface WxCouponOrderService { | |||
| @@ -62,34 +64,35 @@ public interface WxCouponOrderService { | |||
| ResultData verify(Long couponOrderId, Long bUserId); | |||
| /** | |||
| * 根据主键couponOrderId(券码)退券(款) | |||
| * 根据日期 b用户查券list | |||
| * | |||
| * @param couponOrderId | |||
| * @param bUserId 退券(款)人(登录用户) | |||
| * @param bUserId B端用户) | |||
| */ | |||
| ResultData refund(Long couponOrderId, Long bUserId); | |||
| ResultData listOnDateAsPage(Long bUserId, String date, Integer pageIndex, Integer pageSize, boolean isVerified); | |||
| /** | |||
| * 根据日期 b用户查券list | |||
| * C用户查券list | |||
| * | |||
| * @param bUserId B端用户) | |||
| * @param record C端用户 | |||
| */ | |||
| ResultData listOnDateAsPage(Long bUserId, String date, Integer pageIndex, Integer pageSize, boolean isVerified); | |||
| ResultData listCUserVoAsPage(WxCouponOrderCVo record, Integer pageIndex, Integer pageSize); | |||
| /** | |||
| * C用户查券list | |||
| * C用户查券carlist | |||
| * | |||
| * @param bUserId C端用户 | |||
| * @param record C端用户 | |||
| */ | |||
| ResultData listCUserVoAsPage(WxCouponOrder record, Integer pageIndex, Integer pageSize); | |||
| ResultData carlistCUserVoAsPage(WxCouponOrderCarCVo record, Integer pageIndex, Integer pageSize); | |||
| List<WxCouponOrderCarCVo> carlistCUserVo(WxCouponOrderCarCVo record); | |||
| /** | |||
| * C用户查券详情 | |||
| * | |||
| * @param bUserId C端用户 | |||
| * @param cUserId C端用户 | |||
| */ | |||
| ResultData detailCUserVo(Long cUserId, String couponOrderId); | |||
| @@ -0,0 +1,45 @@ | |||
| package com.simple.service; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.simple.common.ResultData; | |||
| import com.simple.domain.po.WxMallApply; | |||
| import com.simple.domain.po.WxMsgValidationcode; | |||
| public interface WxMallApplyService { | |||
| /** | |||
| * 根据实体查询分页列表 | |||
| * | |||
| * @param record | |||
| * @param offset | |||
| * @param limit | |||
| * @return | |||
| */ | |||
| PageInfo<WxMallApply> listAsPage(WxMallApply record, Integer pageIndex, Integer pageSize); | |||
| /** | |||
| * 根据Id获得实体 | |||
| * | |||
| * @param id | |||
| * @return | |||
| */ | |||
| WxMallApply getById(String id); | |||
| /** | |||
| * 保存或更新实体 | |||
| * | |||
| * @param record | |||
| */ | |||
| void saveOrUpdate(WxMallApply record); | |||
| /** | |||
| * 根据Id删除实体 | |||
| * | |||
| * @param id | |||
| */ | |||
| void deleteById(String id); | |||
| ResultData sendvalidationcode(WxMsgValidationcode wxMsgValidationcode); | |||
| } | |||
| @@ -33,12 +33,12 @@ public interface WxMerchantService { | |||
| */ | |||
| WxMerchant getById(Long id); | |||
| /** | |||
| /** | |||
| * 保存或更新实体 | |||
| * | |||
| * @param record | |||
| */ | |||
| void saveOrUpdate(WxMerchant record); | |||
| void saveOrUpdate(WxMerchant record); | |||
| /** | |||
| * 根据Id删除实体 | |||
| @@ -39,9 +39,9 @@ public interface WxMsgCallbackService { | |||
| void deleteById(Long id); | |||
| void saveOrUpdate(String bid, String item, String sign); | |||
| void saveOrUpdate(String tenantId, String bid, String item, String sign); | |||
| void receivemodel(String bid, Map<String,String> param); | |||
| void receivemodel(String tenantId, String bid, Map<String, String> param); | |||
| void receiveverifymodel(String bid, Map<String,String> param); | |||
| @@ -1,6 +1,5 @@ | |||
| package com.simple.service; | |||
| import java.util.*; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.simple.common.ResultData; | |||
| import com.simple.domain.po.WxMsgSignature; | |||
| @@ -40,6 +39,6 @@ public interface WxMsgSignatureService { | |||
| void deleteById(Long id); | |||
| ResultData getsignaturelist(); | |||
| ResultData getsignaturelist(String tenantId); | |||
| } | |||
| @@ -18,7 +18,7 @@ public interface WxPayOrderService { | |||
| * @param payWay | |||
| * @return | |||
| */ | |||
| ResultData createPayOrder(boolean isReal, WxAppinfo appInfo, WxCUser user, WxPayOrder record, EnumPayWay payWay); | |||
| ResultData createPayOrder(boolean isReal, boolean isShare, WxAppinfo appInfo, WxCUser user, WxPayOrder record, EnumPayWay payWay); | |||
| /** | |||
| * 微信支付订单查询 | |||
| @@ -109,5 +109,7 @@ public interface WxPayOrderService { | |||
| */ | |||
| void deleteById(Long id); | |||
| void sendPaySuccess(); | |||
| } | |||
| @@ -2,6 +2,8 @@ package com.simple.service; | |||
| import java.util.*; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.simple.common.ResultData; | |||
| import com.simple.domain.po.WxMerchant; | |||
| import com.simple.domain.po.WxProfitSharingReceiver; | |||
| public interface WxProfitSharingReceiverService { | |||
| @@ -37,12 +39,11 @@ public interface WxProfitSharingReceiverService { | |||
| * @param id | |||
| */ | |||
| void deleteById(Long id); | |||
| ResultData addReceiver(WxMerchant merchant, WxProfitSharingReceiver receiver); | |||
| ResultData delReceiver(WxMerchant merchant, WxProfitSharingReceiver receiver); | |||
| } | |||
| @@ -7,6 +7,7 @@ import com.simple.domain.po.WxAppinfo; | |||
| import com.simple.domain.po.WxPayOrder; | |||
| import com.simple.domain.po.WxRefundOrder; | |||
| import com.simple.enums.EnumPayWay; | |||
| import com.simple.enums.EnumRefundWay; | |||
| public interface WxRefundOrderService { | |||
| @@ -14,12 +15,12 @@ public interface WxRefundOrderService { | |||
| * 创建退款订单 | |||
| * @param isReal | |||
| * @param appInfo | |||
| * @param record 退款订单请求 | |||
| * @param payOrder 支付订单 | |||
| * @param payWay | |||
| * @param couponOrderId 券包Id | |||
| * @param refundWay 退款来源 | |||
| * @param bUserId b端退款Id,auto,admin,self可为null | |||
| * @return | |||
| */ | |||
| ResultData createRefundOrder(boolean isReal, WxAppinfo appInfo, WxRefundOrder record, WxPayOrder payOrder, EnumPayWay payWay); | |||
| ResultData createRefundOrder(boolean isReal, WxAppinfo appInfo, Long couponOrderId, EnumRefundWay refundWay, Long bUserId); | |||
| /** | |||
| * 退款订单查询 | |||
| @@ -0,0 +1,48 @@ | |||
| package com.simple.service; | |||
| import java.util.*; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.simple.domain.po.WxTemplateMsg; | |||
| public interface WxTemplateMsgService { | |||
| /** | |||
| * 根据实体查询分页列表 | |||
| * | |||
| * @param record | |||
| * @param offset | |||
| * @param limit | |||
| * @return | |||
| */ | |||
| PageInfo<WxTemplateMsg> listAsPage(WxTemplateMsg record, Integer pageIndex, Integer pageSize); | |||
| /** | |||
| * 根据Id获得实体 | |||
| * | |||
| * @param id | |||
| * @return | |||
| */ | |||
| WxTemplateMsg getById(Long id); | |||
| /** | |||
| * 保存或更新实体 | |||
| * | |||
| * @param record | |||
| */ | |||
| void saveOrUpdate(WxTemplateMsg record); | |||
| /** | |||
| * 根据Id删除实体 | |||
| * | |||
| * @param id | |||
| */ | |||
| void deleteById(Long id); | |||
| } | |||
| @@ -83,7 +83,7 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||
| if(result) { | |||
| return new ResultData(); | |||
| }else { | |||
| return new ResultData(Result.ERROR,"请确认券状态,及有效期"); | |||
| return new ResultData(Result.ERROR,"请检查券的有效期以及投放截止时间"); | |||
| } | |||
| @@ -11,10 +11,13 @@ import com.simple.domain.po.*; | |||
| import com.simple.domain.vo.CUserDateAmountVo; | |||
| import com.simple.domain.vo.WxCouponOrderBVo; | |||
| import com.simple.domain.vo.WxCouponOrderCVo; | |||
| import com.simple.domain.vo.WxCouponOrderCarCVo; | |||
| import com.simple.enums.EnumCouponOrderStatus; | |||
| import com.simple.enums.EnumCouponSendType; | |||
| import com.simple.exception.MallinkException; | |||
| import com.simple.mapper.*; | |||
| import com.simple.service.WxCouponOrderService; | |||
| import com.simple.service.WxCouponSendService; | |||
| import com.simple.service.WxOrderService; | |||
| import org.apache.log4j.Logger; | |||
| import org.apache.poi.ss.usermodel.Workbook; | |||
| @@ -52,13 +55,14 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| @Autowired | |||
| WxOrderService wxOrderService; | |||
| @Autowired | |||
| WxCouponSendService wxCouponSendService; | |||
| @Override | |||
| public PageInfo<WxCouponOrder> listAsPage(WxCouponOrder record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponOrderMapper.findList(record)); | |||
| } | |||
| @Override | |||
| public WxCouponOrder getById(Long id) { | |||
| return wxCouponOrderMapper.selectByPrimaryKey(id); | |||
| @@ -161,11 +165,21 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| } | |||
| @Override | |||
| public ResultData listCUserVoAsPage(WxCouponOrder record, Integer pageIndex, Integer pageSize) { | |||
| public ResultData listCUserVoAsPage(WxCouponOrderCVo record, Integer pageIndex, Integer pageSize) { | |||
| return new ResultData(PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponOrderMapper.findListOfCUser(record))); | |||
| } | |||
| @Override | |||
| public ResultData carlistCUserVoAsPage(WxCouponOrderCarCVo record, Integer pageIndex, Integer pageSize) { | |||
| return new ResultData(PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponOrderMapper.findCarListOfCUser(record))); | |||
| } | |||
| @Override | |||
| public List<WxCouponOrderCarCVo> carlistCUserVo(WxCouponOrderCarCVo record) { | |||
| return wxCouponOrderMapper.findCarListOfCUser(record); | |||
| } | |||
| @Override | |||
| public ResultData detailCUserVo(Long cUserId, String couponOrderId) { | |||
| WxCUser wxCuser = wxCUserMapper.selectByPrimaryKey(cUserId); | |||
| @@ -319,67 +333,13 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| logger.error("db failed: couponOrder-" + couponOrderId + ", e:" + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | |||
| } | |||
| return new ResultData(wxCouponOrder); | |||
| } | |||
| @Override | |||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||
| public ResultData refund(Long couponOrderId, Long bUserId) { | |||
| WxCouponOrder wxCouponOrder = wxCouponOrderMapper.selectByPrimaryKey(couponOrderId); | |||
| if(wxCouponOrder == null){ | |||
| logger.error("券ID不存在:"+ couponOrderId); | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); | |||
| } | |||
| WxOrder wxOrder = wxOrderMapper.selectByPrimaryKey(wxCouponOrder.getOrderId()); | |||
| if(bUserId != wxCouponOrder.getCUserId()) { | |||
| // TODO web管理端退款 | |||
| // B端用户退款 | |||
| WxMerchantBUser wxMerchantBUser = wxMerchantBUserMapper.selectByPrimaryKey(bUserId.longValue()); | |||
| if (wxMerchantBUser == null) { | |||
| logger.error("操作员ID不存在:" + bUserId); | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); | |||
| } | |||
| if (!wxOrder.getMerchantId().equals(wxMerchantBUser.getMerchantId())) { | |||
| logger.error("券: couponMerchantId-" + wxOrder.getMerchantId() + "核销: couponMerchantId-" + wxMerchantBUser.getMerchantId()); | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); | |||
| } | |||
| } else { | |||
| logger.info("自己发起退款, userId: " + bUserId); | |||
| } | |||
| // 核销发券 | |||
| wxCouponSendService.sendCouponToUser(wxMerchantBUser.getTenantId(), wxOrder.getCUserId(), EnumCouponSendType.COUPON_VERIFY.getCode()); | |||
| if (wxCouponOrder.getCouponOrderStatus().equals(EnumCouponOrderStatus.COUPON_ORDER_OVER_TIME.getCode())) { | |||
| logger.error("已过期: couponOrder-" + couponOrderId); | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_OVER_TIME); | |||
| } | |||
| if (wxCouponOrder.getCouponOrderStatus().equals(EnumCouponOrderStatus.COUPON_ORDER_INVALID.getCode())) { | |||
| logger.error("已退款: couponOrder-" + couponOrderId); | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_OVER_TIME); | |||
| } | |||
| if (wxCouponOrder.getCouponOrderStatus().equals(EnumCouponOrderStatus.COUPON_ORDER_USED.getCode())) { | |||
| logger.error("已经核销过的券: couponOrder-" + couponOrderId); | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_USED); | |||
| } | |||
| try { | |||
| wxCouponOrder.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_INVALID.getCode()); //3退款,券作废 | |||
| wxCouponOrder.setBUserId(bUserId); | |||
| wxCouponOrder.setUpdateDate(new Date()); | |||
| wxCouponOrderMapper.updateByPrimaryKeySelective(wxCouponOrder); | |||
| } catch (Exception e) { | |||
| logger.error("db failed: couponOrder-" + couponOrderId + ", e:" + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | |||
| } | |||
| // 库存回复+1 | |||
| wxOrderService.stockBack(wxOrder); | |||
| return new ResultData(wxCouponOrder); | |||
| } | |||
| @Override | |||
| public List<CUserDateAmountVo> queryPriceTotalGroup(String tenantId, Date startTime, Date endTime) { | |||
| @@ -0,0 +1,164 @@ | |||
| package com.simple.service.impl; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.simple.common.ErrorCode; | |||
| import com.simple.common.IdWorker; | |||
| import com.simple.common.Result; | |||
| import com.simple.common.ResultData; | |||
| import com.simple.domain.po.WxMallApply; | |||
| import com.simple.domain.po.WxMsgConfig; | |||
| import com.simple.domain.po.WxMsgValidationcode; | |||
| import com.simple.domain.po.WxMsgValidationcodeModel; | |||
| import com.simple.mapper.WxMallApplyMapper; | |||
| import com.simple.mapper.WxMsgConfigMapper; | |||
| import com.simple.mapper.WxMsgValidationcodeMapper; | |||
| import com.simple.mapper.WxMsgValidationcodeModelMapper; | |||
| import com.simple.service.WxMallApplyService; | |||
| import com.simple.utils.AesUtil; | |||
| import com.simple.utils.HMACSHA256; | |||
| import com.simple.utils.HttpUtil; | |||
| import com.simple.utils.RsaUtil; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import java.util.*; | |||
| import java.util.stream.Collectors; | |||
| @Service | |||
| public class WxMallApplyServiceImpl implements WxMallApplyService { | |||
| @Autowired | |||
| WxMallApplyMapper wxMallApplyMapper; | |||
| @Autowired | |||
| WxMsgValidationcodeMapper wxMsgValidationcodeMapper; | |||
| @Autowired | |||
| WxMsgConfigMapper wxMsgConfigMapper; | |||
| @Autowired | |||
| WxMsgValidationcodeModelMapper wxMsgValidationcodeModelMapper; | |||
| @Override | |||
| public PageInfo<WxMallApply> listAsPage(WxMallApply record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxMallApplyMapper.findList(record)); | |||
| } | |||
| @Override | |||
| public WxMallApply getById(String id) { | |||
| return wxMallApplyMapper.selectByPrimaryKey(id); | |||
| } | |||
| @Override | |||
| public void saveOrUpdate(WxMallApply record) { | |||
| if (record.getId() == null) { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| record.setId(idWorker.nextId()); | |||
| record.setApplyDate(new Date()); | |||
| wxMallApplyMapper.insertSelective(record); | |||
| } else { | |||
| wxMallApplyMapper.updateByPrimaryKeySelective(record); | |||
| } | |||
| } | |||
| @Override | |||
| public void deleteById(String id) { | |||
| wxMallApplyMapper.deleteByPrimaryKey(id); | |||
| } | |||
| @Override | |||
| public ResultData sendvalidationcode(WxMsgValidationcode wxMsgValidationcode) { | |||
| //1、查看是否存在未过期的短信,有返回成功 没有继续 | |||
| List<WxMsgValidationcode> wxmsgvalidationcodelist = wxMsgValidationcodeMapper.findList(wxMsgValidationcode); | |||
| Date currentdate = new Date(); | |||
| wxmsgvalidationcodelist = wxmsgvalidationcodelist.stream().filter(validationcode -> | |||
| validationcode.getExpiretime().after(currentdate)).collect(Collectors.toList()); | |||
| if(wxmsgvalidationcodelist.size()>0) return new ResultData(ErrorCode.MSG_REPEAT_SEND.getCode(),ErrorCode.MSG_REPEAT_SEND.getMessage()); | |||
| //3、从短信配置中查询密钥 bid 等信息 | |||
| WxMsgConfig wxMsgConfig = new WxMsgConfig(); | |||
| wxMsgConfig.setTenantId(wxMsgValidationcode.getTenantId()); | |||
| List<WxMsgConfig> wxMsgConfigs = wxMsgConfigMapper.findList(wxMsgConfig); | |||
| if (wxMsgConfigs.size() == 0) new ResultData(500,"发送失败"); | |||
| wxMsgConfig = wxMsgConfigs.get(0); | |||
| WxMsgValidationcodeModel wxMsgValidationcodeModel = new WxMsgValidationcodeModel(); | |||
| wxMsgValidationcodeModel.setTenantId(wxMsgConfig.getTenantId()); | |||
| wxMsgValidationcodeModel.setType(wxMsgValidationcode.getType()); | |||
| wxMsgValidationcodeModel = wxMsgValidationcodeModelMapper.findList(wxMsgValidationcodeModel).get(0); | |||
| wxMsgValidationcode.setSignature(wxMsgValidationcodeModel.getSignature()); | |||
| String secret = wxMsgConfig.getSecret(); | |||
| String bid = wxMsgConfig.getBid(); | |||
| String publickey = wxMsgConfig.getPublickey(); | |||
| //验证码 | |||
| int code = (int) ((Math.random() * 9 + 1) * 100000); | |||
| String phone = wxMsgValidationcode.getPhone(); | |||
| String signature = wxMsgValidationcode.getSignature(); | |||
| //内容 | |||
| String msg = wxMsgValidationcodeModel.getContent().replace("{s6}", String.valueOf(code)); | |||
| wxMsgValidationcode.setCode(String.valueOf(code)); | |||
| wxMsgValidationcode.setMsg(msg); | |||
| String notifyUrl = wxMsgConfig.getNotifyurl(); | |||
| TreeMap<String, String> message = new TreeMap<>(); | |||
| message.put("bid", bid); | |||
| message.put("phone", phone); | |||
| message.put("signature", signature); | |||
| message.put("msg", msg); | |||
| message.put("notify_url", notifyUrl); | |||
| message.put("verifysms","1"); | |||
| StringBuilder sb = new StringBuilder(); | |||
| Set<Map.Entry<String, String>> entries = message.entrySet(); | |||
| for (Map.Entry<String, String> entry : entries) { | |||
| sb.append(entry.getKey()).append("=").append(entry.getValue()); | |||
| } | |||
| sb.append("&secret=").append(secret); | |||
| String sign = HMACSHA256.sha256_HMAC(sb.toString(), secret); | |||
| message.put("sign", sign.toUpperCase()); | |||
| String str32 = HMACSHA256.STR2; | |||
| String iv = HMACSHA256.IV; | |||
| Map<String, String> params = new HashMap<>(); | |||
| params.put("iv", iv); | |||
| params.put("bid", bid); | |||
| try { | |||
| String data = AesUtil.AESEncode(str32, JSONObject.toJSONString(message), iv); | |||
| String sc = RsaUtil.RSAEncode(str32.getBytes(), publickey); | |||
| params.put("data", data); | |||
| params.put("sc", sc); | |||
| } catch (Exception e) { | |||
| throw new RuntimeException("发送失败"); | |||
| } | |||
| String requestUrl = "https://webapp.wiwide.com/apisms/send"; | |||
| String result = HttpUtil.doPost(requestUrl, params); | |||
| JSONObject jsonObjectResult = JSONObject.parseObject(result); | |||
| String ret = jsonObjectResult.get("ret").toString(); | |||
| if (ret.equals("1")) { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| wxMsgValidationcode.setId(idWorker.nextId()); | |||
| long currentTime = System.currentTimeMillis() ; | |||
| Date createtime=new Date(currentTime); | |||
| Integer minutes = wxMsgValidationcodeModel.getMinutes(); | |||
| currentTime +=minutes*60*1000; | |||
| Date expiredate=new Date(currentTime); | |||
| wxMsgValidationcode.setExpiretime(expiredate); | |||
| wxMsgValidationcode.setCreatetime(createtime); | |||
| wxMsgValidationcodeMapper.insertSelective(wxMsgValidationcode); | |||
| return new ResultData(Result.SUCCESS,"发送成功"); | |||
| } | |||
| return new ResultData(500,"发送失败"); | |||
| } | |||
| } | |||
| @@ -15,6 +15,8 @@ import org.springframework.transaction.annotation.Transactional; | |||
| import java.util.ArrayList; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| import java.util.stream.Collectors; | |||
| @Service | |||
| public class WxMerchantServiceImpl implements WxMerchantService { | |||
| @@ -36,7 +38,23 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| @Override | |||
| public PageInfo<WxMerchant> listAsPage(WxMerchant record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxMerchantMapper.findList(record)); | |||
| WxMerchantShop merchantShop = new WxMerchantShop(); | |||
| merchantShop.setTenantId(record.getTenantId()); | |||
| merchantShop.setIsDel(0); | |||
| List<WxMerchantShop> merchantShops = wxMerchantShopMapper.findList(merchantShop); | |||
| PageHelper.startPage(pageIndex, pageSize); | |||
| List<WxMerchant> merchants = wxMerchantMapper.findList(record); | |||
| for(WxMerchant merchant:merchants){ | |||
| List<WxMerchantShop> collect = merchantShops.stream().filter(ms -> ms.getMerchantId().equals(merchant.getId())).collect(Collectors.toList()); | |||
| if(collect!=null && collect.size()>0){ | |||
| merchant.setRentalStartDate(collect.get(0).getRentalStartDate()); | |||
| merchant.setRentalEndDate(collect.get(0).getRentalEndDate()); | |||
| } | |||
| } | |||
| PageInfo<WxMerchant> pageInfo = new PageInfo<>(merchants); | |||
| return pageInfo; | |||
| } | |||
| @Override | |||
| @@ -50,10 +68,13 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| WxMerchant wxMerchant = wxMerchantMapper.selectByPrimaryKey(id); | |||
| WxMerchantShop wxMerchantShop=new WxMerchantShop(); | |||
| wxMerchantShop.setMerchantId(wxMerchant.getId()); | |||
| wxMerchantShop.setIsDel(0); | |||
| List<WxShop> shops = new ArrayList<>(); | |||
| List<WxMerchantShop> wxMerchantShopList = wxMerchantShopMapper.findList(wxMerchantShop); | |||
| for(WxMerchantShop merchantShop:wxMerchantShopList){ | |||
| wxMerchant.setRentalStartDate(merchantShop.getRentalStartDate()); | |||
| wxMerchant.setRentalEndDate(merchantShop.getRentalEndDate()); | |||
| WxShop wxShop = WxShopMapper.selectByPrimaryKey(merchantShop.getShopId()); | |||
| if(wxShop!=null) | |||
| shops.add(wxShop); | |||
| @@ -113,8 +134,9 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| Date shopdate = new Date(); | |||
| wxMerchantShop.setUpdateDate(shopdate); | |||
| wxMerchantShop.setCreateDate(shopdate); | |||
| wxMerchantShop.setRentalEndDate(shopdate); | |||
| wxMerchantShop.setRentalStartDate(shopdate); | |||
| wxMerchantShop.setIsDel(0); | |||
| wxMerchantShop.setRentalStartDate(wxMerchant.getRentalStartDate()); | |||
| wxMerchantShop.setRentalEndDate(wxMerchant.getRentalEndDate()); | |||
| wxMerchantShopMapper.insertSelective(wxMerchantShop); | |||
| //更新商铺状态 | |||
| @@ -155,7 +177,8 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| wxMerchantShopQuery.setMerchantId(wxMerchant.getId()); | |||
| List<WxMerchantShop> wxMerchantShopList = wxMerchantShopMapper.findList(wxMerchantShopQuery); | |||
| for(WxMerchantShop merchantShop:wxMerchantShopList){ | |||
| wxMerchantShopMapper.delete(merchantShop); | |||
| merchantShop.setIsDel(1); | |||
| wxMerchantShopMapper.updateByPrimaryKeySelective(merchantShop); | |||
| //更新商铺状态 | |||
| WxShop wxShop = new WxShop(); | |||
| @@ -175,8 +198,9 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| Date shopdate = new Date(); | |||
| wxMerchantShop.setUpdateDate(shopdate); | |||
| wxMerchantShop.setCreateDate(shopdate); | |||
| wxMerchantShop.setRentalEndDate(shopdate); | |||
| wxMerchantShop.setRentalStartDate(shopdate); | |||
| wxMerchantShop.setRentalStartDate(wxMerchant.getRentalStartDate()); | |||
| wxMerchantShop.setRentalEndDate(wxMerchant.getRentalEndDate()); | |||
| wxMerchantShop.setIsDel(0); | |||
| wxMerchantShopMapper.insertSelective(wxMerchantShop); | |||
| //更新商铺状态 | |||
| @@ -63,9 +63,10 @@ public class WxMsgCallbackServiceImpl implements WxMsgCallbackService { | |||
| } | |||
| @Override | |||
| public void saveOrUpdate(String bid, String item, String sign) { | |||
| public void saveOrUpdate(String tenantId,String bid, String item, String sign) { | |||
| WxMsgConfig wxMsgConfig = new WxMsgConfig(); | |||
| wxMsgConfig.setTenantId(tenantId); | |||
| wxMsgConfig.setBid(bid); | |||
| List<WxMsgConfig> list = wxMsgConfigMapper.findList(wxMsgConfig); | |||
| if(list.size()==1) { | |||
| @@ -84,8 +85,9 @@ public class WxMsgCallbackServiceImpl implements WxMsgCallbackService { | |||
| } | |||
| @Override | |||
| public void receivemodel(String bid, Map<String, String> param) { | |||
| public void receivemodel(String tenantId, String bid, Map<String, String> param) { | |||
| WxMsgConfig wxMsgConfig = new WxMsgConfig(); | |||
| wxMsgConfig.setTenantId(tenantId); | |||
| wxMsgConfig.setBid(bid); | |||
| List<WxMsgConfig> list = wxMsgConfigMapper.findList(wxMsgConfig); | |||
| if(list.size()==1) { | |||
| @@ -3,6 +3,7 @@ package com.simple.service.impl; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.simple.common.ErrorCode; | |||
| import com.simple.common.IdWorker; | |||
| import com.simple.common.Result; | |||
| import com.simple.common.ResultData; | |||
| @@ -46,7 +47,7 @@ public class WxMsgModelServiceImpl implements WxMsgModelService { | |||
| WxMsgConfig wxMsgConfig = new WxMsgConfig(); | |||
| wxMsgConfig.setTenantId(wxMsgModel.getTenantId()); | |||
| List<WxMsgConfig> wxMsgConfigs = wxMsgConfigMapper.findList(wxMsgConfig); | |||
| if(wxMsgConfigs.size()==0)return new ResultData(Result.SUCCESS, "您还未接入短信运营商,请联系平台管理员"); | |||
| if(wxMsgConfigs.size()==0)return new ResultData(ErrorCode.MSG_SERVER_NOT_FIND.getCode(), "您还未接入短信运营商,请联系平台管理员"); | |||
| wxMsgConfig = wxMsgConfigs.get(0); | |||
| String secret = wxMsgConfig.getSecret(); | |||
| @@ -56,12 +57,12 @@ public class WxMsgModelServiceImpl implements WxMsgModelService { | |||
| //查看用户最新数据是否存在 | |||
| List<WxMsgModel> wxMsgModels = wxMsgModelMapper.findList(wxMsgModel); | |||
| if (wxMsgModel.getId() == null && wxMsgModels.size() == 1) { | |||
| return new ResultData(Result.SUCCESS, "您添加的短信模板已存在"); | |||
| return new ResultData(ErrorCode.MSG_TEMPLATE_REPEAT.getCode(), "您添加的短信模板已存在"); | |||
| } | |||
| if (wxMsgModel.getId() != null && wxMsgModels.size() == 1) { | |||
| WxMsgModel wxmsgmodel = wxMsgModels.get(0); | |||
| if(wxmsgmodel.getContent().equals(wxMsgModel.getContent()) && wxmsgmodel.getSignature().equals(wxMsgModel.getSignature())) { | |||
| return new ResultData(Result.SUCCESS, "您添加的短信模板已存在"); | |||
| return new ResultData(ResultData.SUCCESS, "修改成功"); | |||
| } | |||
| } | |||
| @@ -100,7 +101,7 @@ public class WxMsgModelServiceImpl implements WxMsgModelService { | |||
| String result = HttpUtil.doPost(requestUrl, params); | |||
| JSONObject jsonObjectResult = JSONObject.parseObject(result); | |||
| String ret = jsonObjectResult.get("ret").toString(); | |||
| if (ret.equals("1") || ret.equals("-6")) { | |||
| if (ret.equals("1")) { | |||
| if (wxMsgModel.getId() == null) { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| wxMsgModel.setId(idWorker.nextId()); | |||
| @@ -114,10 +115,23 @@ public class WxMsgModelServiceImpl implements WxMsgModelService { | |||
| wxMsgModelMapper.updateByPrimaryKeySelective(wxMsgModel); | |||
| } | |||
| return new ResultData(Result.SUCCESS, "创建模板成功"); | |||
| }else if(ret.equals("-6")){ | |||
| if (wxMsgModel.getId() == null) { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| wxMsgModel.setId(idWorker.nextId()); | |||
| wxMsgModel.setTenantId(wxMsgModel.getTenantId()); | |||
| String data = jsonObjectResult.get("data").toString(); | |||
| wxMsgModel.setModelId(Integer.valueOf(data)); | |||
| wxMsgModel.setCreatetime(new Date()); | |||
| wxMsgModel.setStatus(1); | |||
| wxMsgModelMapper.insertSelective(wxMsgModel); | |||
| } else { | |||
| wxMsgModelMapper.updateByPrimaryKeySelective(wxMsgModel); | |||
| } | |||
| }else if (ret == "-4") { | |||
| return new ResultData(Result.SUCCESS, "短信签名或内容错误"); | |||
| return new ResultData(ErrorCode.MSG_SIGNATURE_CONTENT_ERROR.getCode(), "短信签名或内容错误"); | |||
| } | |||
| return new ResultData(Result.SUCCESS, "创建模板失败"); | |||
| return new ResultData(ErrorCode.MSG_TEMPLATE_CREATE_ERROR.getCode(), "创建模板失败"); | |||
| } | |||
| @Override | |||
| @@ -4,7 +4,6 @@ import java.util.*; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.simple.common.ResultData; | |||
| import com.simple.domain.po.WxMsgModel; | |||
| import com.simple.domain.po.WxMsgSignature; | |||
| import com.simple.mapper.WxMsgSignatureMapper; | |||
| import com.simple.service.WxMsgSignatureService; | |||
| @@ -35,7 +34,6 @@ public class WxMsgSignatureServiceImpl implements WxMsgSignatureService { | |||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| record.setId(idWorker.nextId()); | |||
| record.setTenantId("1"); | |||
| record.setCreatetime(new Date()); | |||
| wxMsgSignatureMapper.insertSelective(record); | |||
| } else { | |||
| @@ -49,9 +47,9 @@ public class WxMsgSignatureServiceImpl implements WxMsgSignatureService { | |||
| } | |||
| @Override | |||
| public ResultData getsignaturelist() { | |||
| public ResultData getsignaturelist(String tenantId) { | |||
| WxMsgSignature wxMsgSignature = new WxMsgSignature(); | |||
| wxMsgSignature.setTenantId("1"); | |||
| wxMsgSignature.setTenantId(tenantId); | |||
| List<WxMsgSignature> list = wxMsgSignatureMapper.findList(wxMsgSignature); | |||
| return new ResultData(list); | |||
| } | |||
| @@ -3,6 +3,7 @@ package com.simple.service.impl; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.simple.common.ErrorCode; | |||
| import com.simple.common.IdWorker; | |||
| import com.simple.common.Result; | |||
| import com.simple.common.ResultData; | |||
| @@ -58,13 +59,16 @@ public class WxMsgValidationcodeModelServiceImpl implements WxMsgValidationcodeM | |||
| //查看用户最新数据是否存在 | |||
| List<WxMsgValidationcodeModel> wxMsgModels = wxMsgValidationcodeModelMapper.findList(wxMsgModel); | |||
| if (wxMsgModel.getId() == null && wxMsgModels.size() == 1) { | |||
| return new ResultData(Result.SUCCESS, "您添加的短信模板已存在"); | |||
| return new ResultData(ErrorCode.MSG_TEMPLATE_REPEAT.getCode(), "您添加的短信模板已存在"); | |||
| } | |||
| if (wxMsgModel.getId() != null && wxMsgModels.size() == 1) { | |||
| //ID相同 内容相同 不发送短信 不做修改 | |||
| WxMsgValidationcodeModel wxmsgmodel = wxMsgModels.get(0); | |||
| if(wxmsgmodel.getContent().equals(wxMsgModel.getContent()) && wxmsgmodel.getSignature().equals(wxMsgModel.getSignature())) { | |||
| return new ResultData(Result.SUCCESS, "您添加的短信模板已存在"); | |||
| return new ResultData(Result.SUCCESS, "修改成功"); | |||
| } | |||
| } | |||
| //请求api数据排序 | |||
| @@ -103,7 +107,7 @@ public class WxMsgValidationcodeModelServiceImpl implements WxMsgValidationcodeM | |||
| String result = HttpUtil.doPost(requestUrl, params); | |||
| JSONObject jsonObjectResult = JSONObject.parseObject(result); | |||
| String ret = jsonObjectResult.get("ret").toString(); | |||
| if (ret.equals("1") || ret.equals("-6")) { | |||
| if (ret.equals("1")) { | |||
| if (wxMsgModel.getId() == null) { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| wxMsgModel.setId(idWorker.nextId()); | |||
| @@ -117,10 +121,23 @@ public class WxMsgValidationcodeModelServiceImpl implements WxMsgValidationcodeM | |||
| wxMsgValidationcodeModelMapper.updateByPrimaryKeySelective(wxMsgModel); | |||
| } | |||
| return new ResultData(Result.SUCCESS, "创建模板成功"); | |||
| }else if(ret.equals("-6")){ | |||
| if (wxMsgModel.getId() == null) { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| wxMsgModel.setId(idWorker.nextId()); | |||
| wxMsgModel.setTenantId(wxMsgModel.getTenantId()); | |||
| String data = jsonObjectResult.get("data").toString(); | |||
| wxMsgModel.setModelId(Integer.valueOf(data)); | |||
| wxMsgModel.setCreatetime(new Date()); | |||
| wxMsgModel.setStatus(1); | |||
| wxMsgValidationcodeModelMapper.insertSelective(wxMsgModel); | |||
| } else { | |||
| wxMsgValidationcodeModelMapper.updateByPrimaryKeySelective(wxMsgModel); | |||
| } | |||
| }else if (ret == "-4") { | |||
| return new ResultData(Result.SUCCESS, "短信签名或内容错误"); | |||
| return new ResultData(ErrorCode.MSG_SIGNATURE_CONTENT_ERROR.getCode(), "短信签名或内容错误"); | |||
| } | |||
| return new ResultData(Result.SUCCESS, "创建模板失败"); | |||
| return new ResultData(ErrorCode.MSG_TEMPLATE_CREATE_ERROR.getCode(), "创建模板失败"); | |||
| } | |||
| @@ -1,29 +1,29 @@ | |||
| package com.simple.service.impl; | |||
| import java.text.ParseException; | |||
| import java.text.SimpleDateFormat; | |||
| import java.util.*; | |||
| import cn.binarywang.wx.miniapp.api.WxMaService; | |||
| import cn.binarywang.wx.miniapp.bean.WxMaTemplateMessage; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.google.common.collect.Lists; | |||
| import com.simple.common.ErrorCode; | |||
| import com.simple.common.Result; | |||
| import com.simple.common.ResultData; | |||
| import com.simple.domain.po.*; | |||
| import com.simple.enums.EnumOrderStatus; | |||
| import com.simple.enums.EnumPayStatus; | |||
| import com.simple.enums.EnumPayType; | |||
| import com.simple.enums.EnumPayWay; | |||
| import com.simple.enums.*; | |||
| import com.simple.exception.MallinkException; | |||
| import com.simple.mapper.*; | |||
| import com.simple.pay.*; | |||
| import com.simple.service.WxOrderService; | |||
| import com.simple.service.WxPayOrderService; | |||
| import com.simple.utils.BeanUtils; | |||
| import com.simple.utils.MapUtil; | |||
| import com.simple.utils.Utility; | |||
| import com.simple.utils.XmlUtil; | |||
| import com.simple.utils.*; | |||
| import me.chanjar.weixin.common.error.WxErrorException; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.apache.log4j.Logger; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| @@ -48,11 +48,21 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| @Autowired | |||
| WxOrderMapper wxOrderMapper; | |||
| @Autowired | |||
| WxOrderService wxOrderService; | |||
| @Autowired | |||
| WxCouponMapper wxCouponMapper; | |||
| @Autowired | |||
| WxPayOrderMapper wxPayOrderMapper; | |||
| @Autowired | |||
| WxOrderService wxOrderService; | |||
| WxTemplateMsgMapper wxTemplateMsgMapper; | |||
| @Autowired | |||
| WxMerchantMapper wxMerchantMapper; | |||
| JSONObject errorMap = JSON.parseObject("{" + | |||
| "\"NOAUTH\":{\"detail\":\"商户无此接口权限\",\"reason\":\"商户未开通此接口权限\",\"resolution\":\"请商户前往申请此接口权限\"}," + | |||
| @@ -84,7 +94,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| "\"XML_FORMAT_ERROR\":{\"detail\":\"XML格式错误\t\",\"reason\":\"XML格式错误\",\"reason\":\"请检查XML参数格式是否正确\"}}"); | |||
| @Override | |||
| public ResultData createPayOrder(boolean isReal, WxAppinfo appInfo, WxCUser user, WxPayOrder record, EnumPayWay payWay) { | |||
| public ResultData createPayOrder(boolean isReal, boolean isShare, WxAppinfo appInfo, WxCUser user, WxPayOrder record, EnumPayWay payWay) { | |||
| final IdWorker idworker = IdWorker.get(); | |||
| try { | |||
| @@ -134,61 +144,126 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| WxPayAccount payAccount = wxPayAccountMapper.selectByPrimaryKey(appInfo.getPayId()); | |||
| if (isReal) { | |||
| // 统一下单 | |||
| String noncestr = Utility.generate32UUID(); | |||
| WxPayOrderP wxPayOrderP = new WxPayOrderP(); | |||
| wxPayOrderP.setOpenid(user.getOpenId()); | |||
| wxPayOrderP.setAppid(user.getAppId()); | |||
| wxPayOrderP.setMch_id(payAccount.getMchId()); | |||
| wxPayOrderP.setNonce_str(noncestr); | |||
| wxPayOrderP.setBody(order.getDetail()); | |||
| wxPayOrderP.setOut_trade_no(record.getPayOrderNo()); | |||
| wxPayOrderP.setTotal_fee(order.getPayment()); | |||
| wxPayOrderP.setSpbill_create_ip(record.getIp()); // 终端IP | |||
| wxPayOrderP.setNotify_url(payAccount.getPayNotifyUrl()); | |||
| wxPayOrderP.setTrade_type(WxPay.TradeType.JSAPI.name()); // 终端类型 | |||
| wxPayOrderP.setProduct_id(String.valueOf(order.getId())); // 订单ID | |||
| wxPayOrderP.setTime_start(Utility.getDataFormatStringYYYYMMDDHHmmss(currentDate)); | |||
| Date futureDate = new Date(); | |||
| futureDate.setTime(currentDate.getTime() + 15*60*1000); | |||
| wxPayOrderP.setTime_expire(Utility.getDataFormatStringYYYYMMDDHHmmss(futureDate)); // 15分钟后结束 | |||
| wxPayOrderP.setSign(WxPayment.createSign(BeanUtils.toStringMap(wxPayOrderP), payAccount.getApiKey())); | |||
| String response = WxPay.pushOrder(BeanUtils.toStringMap(wxPayOrderP)); | |||
| logger.info("pay order, wechat pushOrder, " + wxPayOrderP.toString() + ", response: " + response.toString()); | |||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||
| returnMap.put("payOrderId", payOrderNo); | |||
| String result_code = returnMap.get("result_code"); | |||
| if ("SUCCESS".equals(result_code)) { | |||
| /* | |||
| Map<String, String> signMap = WxPayment.buildWeappSecondSignMap(returnMap.get("appid"), | |||
| String.valueOf(Utility.getCurrentTimeStamp()), | |||
| returnMap.get("prepay_id"), | |||
| payAccount.getApiKey()); | |||
| String signAgent = signMap.remove("sign"); | |||
| returnMap.putAll(signMap); | |||
| returnMap.put("paySign", signAgent); | |||
| */ | |||
| String prepay_id = returnMap.get("prepay_id"); | |||
| String timestamp = String.valueOf(Utility.getCurrentTimeStamp()); | |||
| Map<String, String> sighMap = MapUtil.getOrderMap(); | |||
| sighMap.put("appId", returnMap.get("appid")); | |||
| sighMap.put("timeStamp", timestamp); | |||
| sighMap.put("nonceStr", noncestr); | |||
| sighMap.put("package", "prepay_id=" + prepay_id); | |||
| sighMap.put("signType", "MD5"); | |||
| String signAgent = WxPayment.createSign(sighMap, payAccount.getApiKey()); | |||
| returnMap.put("timeStamp", timestamp); | |||
| returnMap.put("nonceStr", noncestr); | |||
| returnMap.put("package", "prepay_id=" + prepay_id); | |||
| returnMap.put("paySign", signAgent); | |||
| logger.info("back to UI: " +returnMap.toString()); | |||
| return new ResultData(Result.SUCCESS, "创建支付订单成功", returnMap); | |||
| // 微信实际支付 | |||
| if (payAccount.getType() == EnumPayMode.MCH.getCode()) { | |||
| // 统一下单 普通商户模式 | |||
| String noncestr = Utility.generate32UUID(); | |||
| WxPayOrderP wxPayOrderP = new WxPayOrderP(); | |||
| wxPayOrderP.setOpenid(user.getOpenId()); | |||
| wxPayOrderP.setAppid(user.getAppId()); | |||
| wxPayOrderP.setMch_id(payAccount.getMchId()); | |||
| wxPayOrderP.setNonce_str(noncestr); | |||
| wxPayOrderP.setBody(order.getDetail()); | |||
| wxPayOrderP.setOut_trade_no(record.getPayOrderNo()); | |||
| wxPayOrderP.setTotal_fee(order.getPayment()); | |||
| wxPayOrderP.setSpbill_create_ip(record.getIp()); // 终端IP | |||
| wxPayOrderP.setNotify_url(payAccount.getPayNotifyUrl()); | |||
| wxPayOrderP.setTrade_type(WxPay.TradeType.JSAPI.name()); // 终端类型 | |||
| wxPayOrderP.setProduct_id(String.valueOf(order.getId())); // 订单ID | |||
| wxPayOrderP.setTime_start(Utility.getDataFormatStringYYYYMMDDHHmmss(currentDate)); | |||
| Date futureDate = new Date(); | |||
| futureDate.setTime(currentDate.getTime() + 15*60*1000); | |||
| wxPayOrderP.setTime_expire(Utility.getDataFormatStringYYYYMMDDHHmmss(futureDate)); // 15分钟后结束 | |||
| Map<String, String> payOrderMap = BeanUtils.toStringMap(wxPayOrderP); | |||
| wxPayOrderP.setSign(WxPayment.createSign(payOrderMap, payAccount.getApiKey())); | |||
| String response = WxPay.pushOrder(BeanUtils.toStringMap(wxPayOrderP)); | |||
| logger.info("pay order, wechat pushOrder, " + wxPayOrderP.toString() + ", response: " + response.toString()); | |||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||
| returnMap.put("payOrderId", payOrderNo); | |||
| String result_code = returnMap.get("result_code"); | |||
| if ("SUCCESS".equals(result_code)) { | |||
| String prepay_id = returnMap.get("prepay_id"); | |||
| // update payOrder with prepay_id | |||
| record.setPrepayId(prepay_id); | |||
| record.setUpdateTime(new Date()); | |||
| try { | |||
| wxPayOrderMapper.updateByPrimaryKeySelective(record); | |||
| } catch (Exception e) { | |||
| logger.error("pay order update error: " + record.toString()); | |||
| throw new MallinkException(ErrorCode.DB_FAIL); | |||
| } | |||
| String timestamp = String.valueOf(Utility.getCurrentTimeStamp()); | |||
| Map<String, String> sighMap = MapUtil.getOrderMap(); | |||
| sighMap.put("appId", returnMap.get("appid")); | |||
| sighMap.put("timeStamp", timestamp); | |||
| sighMap.put("nonceStr", noncestr); | |||
| sighMap.put("package", "prepay_id=" + prepay_id); | |||
| sighMap.put("signType", "MD5"); | |||
| String signAgent = WxPayment.createSign(sighMap, payAccount.getApiKey()); | |||
| returnMap.put("timeStamp", timestamp); | |||
| returnMap.put("nonceStr", noncestr); | |||
| returnMap.put("package", "prepay_id=" + prepay_id); | |||
| returnMap.put("paySign", signAgent); | |||
| logger.info("back to UI: " +returnMap.toString()); | |||
| return new ResultData(Result.SUCCESS, "创建支付订单成功", returnMap); | |||
| } else { | |||
| JSONObject errObj = errorMap.getJSONObject(result_code); | |||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), errObj.toJSONString(), returnMap); | |||
| } | |||
| } else { | |||
| JSONObject errObj = errorMap.getJSONObject(result_code); | |||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), errObj.toJSONString(), returnMap); | |||
| // 统一下单 // 服务商模式 | |||
| String noncestr = Utility.generate32UUID(); | |||
| WxPayOrderSP wxPayOrderSP = new WxPayOrderSP(); | |||
| wxPayOrderSP.setAppid(appInfo.getParentAppId()); | |||
| wxPayOrderSP.setMch_id(payAccount.getMchId()); | |||
| wxPayOrderSP.setSub_appid(user.getAppId()); | |||
| wxPayOrderSP.setSub_mch_id(payAccount.getSubMchId()); | |||
| wxPayOrderSP.setNonce_str(noncestr); | |||
| wxPayOrderSP.setBody(order.getDetail()); | |||
| wxPayOrderSP.setOut_trade_no(record.getPayOrderNo()); | |||
| wxPayOrderSP.setTotal_fee(order.getPayment()); | |||
| wxPayOrderSP.setSpbill_create_ip(record.getIp()); // 终端IP | |||
| wxPayOrderSP.setNotify_url(payAccount.getPayNotifyUrl()); | |||
| wxPayOrderSP.setTrade_type(WxPay.TradeType.JSAPI.name()); // 终端类型 | |||
| wxPayOrderSP.setProduct_id(String.valueOf(order.getId())); // 订单ID | |||
| wxPayOrderSP.setTime_start(Utility.getDataFormatStringYYYYMMDDHHmmss(currentDate)); | |||
| Date futureDate = new Date(); | |||
| futureDate.setTime(currentDate.getTime() + 15*60*1000); | |||
| wxPayOrderSP.setTime_expire(Utility.getDataFormatStringYYYYMMDDHHmmss(futureDate)); // 15分钟后结束 | |||
| Map<String, String> payOrderMap = BeanUtils.toStringMap(wxPayOrderSP); | |||
| if(isShare) { | |||
| payOrderMap.put("profit_sharing", "Y"); | |||
| } | |||
| wxPayOrderSP.setSign(WxPayment.createSign(payOrderMap, payAccount.getApiKey())); | |||
| String response = WxPay.pushOrder(BeanUtils.toStringMap(wxPayOrderSP)); | |||
| logger.info("pay order, wechat pushOrder, " + wxPayOrderSP.toString() + ", response: " + response.toString()); | |||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||
| returnMap.put("payOrderId", payOrderNo); | |||
| String result_code = returnMap.get("result_code"); | |||
| if ("SUCCESS".equals(result_code)) { | |||
| String prepay_id = returnMap.get("prepay_id"); | |||
| // update payOrder with prepay_id | |||
| record.setPrepayId(prepay_id); | |||
| record.setUpdateTime(new Date()); | |||
| try { | |||
| wxPayOrderMapper.updateByPrimaryKeySelective(record); | |||
| } catch (Exception e) { | |||
| logger.error("pay order update error: " + record.toString()); | |||
| throw new MallinkException(ErrorCode.DB_FAIL); | |||
| } | |||
| String timestamp = String.valueOf(Utility.getCurrentTimeStamp()); | |||
| Map<String, String> sighMap = MapUtil.getOrderMap(); | |||
| sighMap.put("appId", returnMap.get("appid")); | |||
| sighMap.put("timeStamp", timestamp); | |||
| sighMap.put("nonceStr", noncestr); | |||
| sighMap.put("package", "prepay_id=" + prepay_id); | |||
| sighMap.put("signType", "MD5"); | |||
| String signAgent = WxPayment.createSign(sighMap, payAccount.getApiKey()); | |||
| returnMap.put("timeStamp", timestamp); | |||
| returnMap.put("nonceStr", noncestr); | |||
| returnMap.put("package", "prepay_id=" + prepay_id); | |||
| returnMap.put("paySign", signAgent); | |||
| logger.info("back to UI: " +returnMap.toString()); | |||
| return new ResultData(Result.SUCCESS, "创建支付订单成功", returnMap); | |||
| } else { | |||
| JSONObject errObj = errorMap.getJSONObject(result_code); | |||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), errObj.toJSONString(), returnMap); | |||
| } | |||
| } | |||
| } else { | |||
| // 虚拟支付 | |||
| WxPayOrderP wxPayOrderP = new WxPayOrderP(); | |||
| wxPayOrderP.setOpenid(user.getOpenId()); | |||
| wxPayOrderP.setAppid(user.getAppId()); | |||
| @@ -224,51 +299,104 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| public ResultData payOrderQuery(WxAppinfo appInfo, WxPayOrder record) { | |||
| // get payAccount | |||
| WxPayAccount payAccount = wxPayAccountMapper.selectByPrimaryKey(appInfo.getPayId()); | |||
| WxPayOrderQ payOrderQ = new WxPayOrderQ(); | |||
| String noncestr = Utility.generate32UUID(); | |||
| payOrderQ.setAppid(appInfo.getAppId()); | |||
| payOrderQ.setMch_id(payAccount.getMchId()); | |||
| payOrderQ.setNonce_str(noncestr); | |||
| payOrderQ.setOut_trade_no(record.getPayOrderNo()); | |||
| if (payAccount.getType() == EnumPayMode.MCH.getCode()) { | |||
| // 普通商户号模式 | |||
| WxPayOrderQ payOrderQ = new WxPayOrderQ(); | |||
| String noncestr = Utility.generate32UUID(); | |||
| payOrderQ.setAppid(appInfo.getAppId()); | |||
| payOrderQ.setMch_id(payAccount.getMchId()); | |||
| payOrderQ.setNonce_str(noncestr); | |||
| payOrderQ.setOut_trade_no(record.getPayOrderNo()); | |||
| try { | |||
| payOrderQ.setSign(WxPayment.createSign(BeanUtils.toStringMap(payOrderQ), payAccount.getApiKey())); | |||
| String response = WxPay.orderQuery(BeanUtils.toStringMap(payOrderQ)); | |||
| logger.info("pay order query, " + payOrderQ.toString() + ", response: " + response); | |||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||
| String result_code = returnMap.get("result_code"); | |||
| if ("SUCCESS".equals(result_code)) { | |||
| String trade_state = returnMap.get("trade_state"); | |||
| //SUCCESS—支付成功 | |||
| //REFUND—转入退款 | |||
| //NOTPAY—未支付 | |||
| //CLOSED—已关闭 | |||
| //REVOKED—已撤销(刷卡支付) | |||
| //USERPAYING--用户支付中 | |||
| //PAYERROR--支付失败(其他原因,如银行返回失败) | |||
| if ("SUCCESS".equals(trade_state)) { | |||
| record.setPayOrderStatus(EnumPayStatus.PAY_WAY_SUCCESS.getCode()); | |||
| handlePayOrderStatusUpdate(record); | |||
| } else if ("USERPAYING".equals(trade_state)) { | |||
| //record.setPayOrderStatus(EnumPayStatus.PAY_WAY_WAIT.getCode()); | |||
| //handlePayOrderStatusUpdate(record); | |||
| try { | |||
| Map map = BeanUtils.toStringMap(payOrderQ); | |||
| payOrderQ.setSign(WxPayment.createSign(map, payAccount.getApiKey())); | |||
| map = BeanUtils.toStringMap(payOrderQ); | |||
| String response = WxPay.orderQuery(map); | |||
| logger.info("pay order query, " + payOrderQ.toString() + ", response: " + response); | |||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||
| String result_code = returnMap.get("result_code"); | |||
| if ("SUCCESS".equals(result_code)) { | |||
| String trade_state = returnMap.get("trade_state"); | |||
| //SUCCESS—支付成功 | |||
| //REFUND—转入退款 | |||
| //NOTPAY—未支付 | |||
| //CLOSED—已关闭 | |||
| //REVOKED—已撤销(刷卡支付) | |||
| //USERPAYING--用户支付中 | |||
| //PAYERROR--支付失败(其他原因,如银行返回失败) | |||
| if ("SUCCESS".equals(trade_state)) { | |||
| record.setPayOrderStatus(EnumPayStatus.PAY_WAY_SUCCESS.getCode()); | |||
| handlePayOrderStatusUpdate(record); | |||
| } else if ("USERPAYING".equals(trade_state)) { | |||
| //record.setPayOrderStatus(EnumPayStatus.PAY_WAY_WAIT.getCode()); | |||
| //handlePayOrderStatusUpdate(record); | |||
| } else { | |||
| record.setPayOrderStatus(EnumPayStatus.PAY_WAY_FAIL.getCode()); | |||
| handlePayOrderStatusUpdate(record); | |||
| } | |||
| return new ResultData(Result.SUCCESS, "订单查询成功", returnMap); | |||
| } else { | |||
| record.setPayOrderStatus(EnumPayStatus.PAY_WAY_FAIL.getCode()); | |||
| handlePayOrderStatusUpdate(record); | |||
| JSONObject errObj = errorMap.getJSONObject(result_code); | |||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), errObj.toJSONString(), returnMap); | |||
| } | |||
| return new ResultData(Result.SUCCESS, "订单查询成功", returnMap); | |||
| } else { | |||
| JSONObject errObj = errorMap.getJSONObject(result_code); | |||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), errObj.toJSONString(), returnMap); | |||
| } 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()); | |||
| } | |||
| } 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 payOrderSQ = new WxPayOrderSQ(); | |||
| String noncestr = Utility.generate32UUID(); | |||
| payOrderSQ.setAppid(appInfo.getParentAppId()); | |||
| payOrderSQ.setSub_appid(appInfo.getAppId()); | |||
| payOrderSQ.setMch_id(payAccount.getMchId()); | |||
| payOrderSQ.setSub_mch_id(payAccount.getSubMchId()); | |||
| payOrderSQ.setNonce_str(noncestr); | |||
| payOrderSQ.setOut_trade_no(record.getPayOrderNo()); | |||
| try { | |||
| Map map = BeanUtils.toStringMap(payOrderSQ); | |||
| payOrderSQ.setSign(WxPayment.createSign(map, payAccount.getApiKey())); | |||
| map = BeanUtils.toStringMap(payOrderSQ); | |||
| String response = WxPay.orderQuery(map); | |||
| logger.info("pay order query, " + payOrderSQ.toString() + ", response: " + response); | |||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||
| String result_code = returnMap.get("result_code"); | |||
| if ("SUCCESS".equals(result_code)) { | |||
| String trade_state = returnMap.get("trade_state"); | |||
| //SUCCESS—支付成功 | |||
| //REFUND—转入退款 | |||
| //NOTPAY—未支付 | |||
| //CLOSED—已关闭 | |||
| //REVOKED—已撤销(刷卡支付) | |||
| //USERPAYING--用户支付中 | |||
| //PAYERROR--支付失败(其他原因,如银行返回失败) | |||
| if ("SUCCESS".equals(trade_state)) { | |||
| record.setPayOrderStatus(EnumPayStatus.PAY_WAY_SUCCESS.getCode()); | |||
| handlePayOrderStatusUpdate(record); | |||
| } else if ("USERPAYING".equals(trade_state)) { | |||
| //record.setPayOrderStatus(EnumPayStatus.PAY_WAY_WAIT.getCode()); | |||
| //handlePayOrderStatusUpdate(record); | |||
| } else { | |||
| record.setPayOrderStatus(EnumPayStatus.PAY_WAY_FAIL.getCode()); | |||
| handlePayOrderStatusUpdate(record); | |||
| } | |||
| return new ResultData(Result.SUCCESS, "订单查询成功", returnMap); | |||
| } else { | |||
| JSONObject errObj = errorMap.getJSONObject(result_code); | |||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), errObj.toJSONString(), returnMap); | |||
| } | |||
| } 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()); | |||
| } | |||
| } | |||
| } | |||
| /** | |||
| * 微信关闭订单 | |||
| @@ -277,33 +405,70 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| public ResultData payOrderClose(WxAppinfo appInfo, WxPayOrder record) { | |||
| // get payAccount | |||
| WxPayAccount payAccount = wxPayAccountMapper.selectByPrimaryKey(appInfo.getPayId()); | |||
| 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()); | |||
| 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 { | |||
| payOrderC.setSign(WxPayment.createSign(BeanUtils.toStringMap(payOrderC), payAccount.getApiKey())); | |||
| try { | |||
| Map map = BeanUtils.toStringMap(payOrderC); | |||
| payOrderC.setSign(WxPayment.createSign(map, payAccount.getApiKey())); | |||
| map = BeanUtils.toStringMap(payOrderC); | |||
| String response = WxPay.closeOrder(map); | |||
| String response = WxPay.closeOrder(BeanUtils.toStringMap(payOrderC)); | |||
| logger.info("pay order close, " + payOrderC.toString() + ", response: " + response); | |||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||
| String result_code = returnMap.get("result_code"); | |||
| if ("SUCCESS".equals(result_code)) { | |||
| record.setPayOrderStatus(EnumPayStatus.PAY_WAY_FAIL.getCode()); | |||
| handlePayOrderStatusUpdate(record); | |||
| return new ResultData(Result.SUCCESS, "订单关闭成功", returnMap); | |||
| } else { | |||
| JSONObject errObj = errorMapClose.getJSONObject(result_code); | |||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), errObj.toJSONString(), returnMap); | |||
| } | |||
| } 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()); | |||
| logger.info("pay order close, " + payOrderC.toString() + ", response: " + response); | |||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||
| String result_code = returnMap.get("result_code"); | |||
| if ("SUCCESS".equals(result_code)) { | |||
| record.setPayOrderStatus(EnumPayStatus.PAY_WAY_FAIL.getCode()); | |||
| handlePayOrderStatusUpdate(record); | |||
| return new ResultData(Result.SUCCESS, "订单关闭成功", returnMap); | |||
| } else { | |||
| JSONObject errObj = errorMapClose.getJSONObject(result_code); | |||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), errObj.toJSONString(), returnMap); | |||
| try { | |||
| Map map = BeanUtils.toStringMap(payOrderSC); | |||
| payOrderSC.setSign(WxPayment.createSign(map, payAccount.getApiKey())); | |||
| map = BeanUtils.toStringMap(payOrderSC); | |||
| String response = WxPay.closeOrder(map); | |||
| logger.info("pay order close, " + payOrderSC.toString() + ", response: " + response); | |||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||
| String result_code = returnMap.get("result_code"); | |||
| if ("SUCCESS".equals(result_code)) { | |||
| record.setPayOrderStatus(EnumPayStatus.PAY_WAY_FAIL.getCode()); | |||
| handlePayOrderStatusUpdate(record); | |||
| return new ResultData(Result.SUCCESS, "订单关闭成功", returnMap); | |||
| } else { | |||
| JSONObject errObj = errorMapClose.getJSONObject(result_code); | |||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), errObj.toJSONString(), returnMap); | |||
| } | |||
| } 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()); | |||
| } | |||
| } 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()); | |||
| } | |||
| } | |||
| @@ -318,12 +483,24 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| @Override | |||
| public String notify(Map<String, String> paramMap, EnumPayWay payWay) { | |||
| // how to get wechatAppId, wechatMchId, partnerKey | |||
| String wechatAppId = paramMap.get("appid"); | |||
| String wechatMchId = paramMap.get("mch_id"); | |||
| WxAppinfo appinfo = wxAppinfoMapper.findByAppId(wechatAppId); | |||
| if (appinfo == null) { | |||
| throw new MallinkException(ErrorCode.APP_ID_NOT_FOUND); | |||
| String appId = paramMap.get("appid"); | |||
| String subAppId = paramMap.get("sub_appid"); | |||
| String mchId = paramMap.get("mch_id"); | |||
| String subMchId = paramMap.get("sub_mch_id"); | |||
| WxAppinfo appinfo = null; | |||
| if (StringUtils.isBlank(subAppId) && StringUtils.isBlank(subMchId)) { | |||
| // 普通商户号 | |||
| appinfo = wxAppinfoMapper.findByAppId(appId); | |||
| if (appinfo == null) { | |||
| throw new MallinkException(ErrorCode.APP_ID_NOT_FOUND); | |||
| } | |||
| } else { | |||
| appinfo = wxAppinfoMapper.findByAppId(subAppId); | |||
| if (appinfo == null) { | |||
| throw new MallinkException(ErrorCode.APP_ID_NOT_FOUND); | |||
| } | |||
| } | |||
| WxPayAccount payAccount = wxPayAccountMapper.selectByPrimaryKey(appinfo.getPayId()); | |||
| if (payAccount == null) { | |||
| throw new MallinkException(ErrorCode.MCH_INFO_NOT_FOUND); | |||
| @@ -385,9 +562,10 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| } catch (RuntimeException e) { | |||
| logger.warn("notify order, alipay checksign error, paramMap: " + paramMap.toString() + ", payWay:" + payWay.toString() + ", e:" + e.getMessage()); | |||
| logger.warn("notify order, checksign error, paramMap: " + paramMap.toString() + ", payWay:" + payWay.toString() + ", e:" + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR); | |||
| } | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "FAILED"); | |||
| @@ -450,13 +628,24 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| logger.error("订单数据库更新失败: " + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "订单数据库更新失败: " + e.getMessage()); | |||
| } | |||
| // 创建couponOrder | |||
| // 微信模板通知用户 | |||
| /* | |||
| try { | |||
| wxOrderService.updateOrderStatus(order, EnumOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS); | |||
| WxAppinfo appinfoQ = new WxAppinfo(); | |||
| appinfoQ.setTenantId(order.getTenantId()); | |||
| appinfoQ.setType(EnumAppType.C.getCode()); | |||
| List<WxAppinfo> appinfoList = wxAppinfoMapper.select(appinfoQ); | |||
| if (appinfoList.size() >0) { | |||
| WxAppinfo appinfo = appinfoList.get(0); | |||
| sendPaySuccessMsg(appinfo, order, updateOrder); | |||
| } | |||
| } catch (Exception e) { | |||
| logger.error("订单数据库更新失败: " + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "订单数据库更新失败: " + e.getMessage()); | |||
| logger.error("微信模板通知error: " + e.getMessage()); | |||
| // throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "订单数据库更新失败: " + e.getMessage()); | |||
| } | |||
| */ | |||
| // End of 微信模板通知用户 | |||
| /* | |||
| Map<String, String> msgMap = new HashMap<>(); | |||
| @@ -586,5 +775,95 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| wxPayOrderMapper.deleteByPrimaryKey(id); | |||
| } | |||
| @Override | |||
| public void sendPaySuccess() { | |||
| /* | |||
| WxAppinfo appinfoQ = new WxAppinfo(); | |||
| appinfoQ.setTenantId("234"); | |||
| appinfoQ.setType(EnumAppType.C.getCode()); | |||
| List<WxAppinfo> appinfoList= wxAppinfoMapper.select(appinfoQ); | |||
| WxAppinfo appinfo = appinfoList.get(0); | |||
| String payOrderIdStr = "196936823522459648"; | |||
| Long payOrderId = Long.valueOf(payOrderIdStr); | |||
| WxPayOrder updateOrder = wxPayOrderMapper.selectByPrimaryKey(payOrderId); | |||
| WxOrder order = wxOrderMapper.selectByPrimaryKey(updateOrder.getOrderId()); | |||
| sendPaySuccessMsg(appinfo, order, updateOrder); | |||
| */ | |||
| } | |||
| /** | |||
| * 微信模板通知用户 | |||
| * @param updateOrder | |||
| * 支付时间 {{keyword1.DATA}} | |||
| * 支付方式 {{keyword2.DATA}} | |||
| * 支付金额 {{keyword3.DATA}} | |||
| * 商品名称 {{keyword4.DATA}} | |||
| * 商家名称 {{keyword5.DATA}} | |||
| * 订单状态 {{keyword6.DATA}} | |||
| */ | |||
| private void sendPaySuccessMsg(WxAppinfo appInfo, WxOrder order, WxPayOrder updateOrder) { | |||
| // 1. get template id | |||
| WxTemplateMsg msgQ = new WxTemplateMsg(); | |||
| msgQ.setTenantId(order.getTenantId()); | |||
| msgQ.setType(EnumTemplateType.PAY_SUCCESS.getCode()); | |||
| WxTemplateMsg msg = null; | |||
| List<WxTemplateMsg> list= wxTemplateMsgMapper.select(msgQ); | |||
| if (list.size() > 0) { | |||
| msg = list.get(0); | |||
| } | |||
| if (msg == null) { | |||
| logger.error("找不到模板Id"); | |||
| throw new MallinkException(ErrorCode.TEMPLATE_NOT_FOUND); | |||
| } | |||
| // 2. get coupon info | |||
| WxCoupon coupon = wxCouponMapper.selectByPrimaryKey(order.getCouponId()); | |||
| if (coupon == null) { | |||
| logger.error("找不到券信息"); | |||
| throw new MallinkException(ErrorCode.COUPON_IS_EMPTY); | |||
| } | |||
| // 3. merchant info | |||
| WxMerchant merchant = wxMerchantMapper.selectByPrimaryKey(order.getMerchantId()); | |||
| if (merchant == null) { | |||
| logger.error("找不到商户信息"); | |||
| throw new MallinkException(ErrorCode.MERCHANT_INFO_NOT_FOUND); | |||
| } | |||
| // 3. get user info | |||
| WxCUser user = wxCUserMapper.selectByPrimaryKey(order.getCUserId()); | |||
| if (user == null) { | |||
| logger.error("找不到C端用户"); | |||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | |||
| } | |||
| if (StringUtils.isBlank(updateOrder.getPrepayId())) { | |||
| logger.error("prepayId为空"); | |||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | |||
| } | |||
| WxMaService wxMaService = MaUtil.getWeappService(appInfo); | |||
| SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); | |||
| WxMaTemplateMessage templateMessage = WxMaTemplateMessage.builder() | |||
| .toUser(user.getOpenId()) | |||
| .formId(updateOrder.getPrepayId()) // 微信支付的formId是prepayId | |||
| .page("pages/index/index") | |||
| .data(Lists.newArrayList( | |||
| new WxMaTemplateMessage.Data("keyword1", dateFormat.format(new Date()), "#173177"), | |||
| new WxMaTemplateMessage.Data("keyword2", "微信支付", "#173177"), | |||
| new WxMaTemplateMessage.Data("keyword3", String.valueOf(updateOrder.getPayAmount()*1.0/100) + "元", "#173177"), | |||
| new WxMaTemplateMessage.Data("keyword4", coupon.getTitle(), "#173177"), | |||
| new WxMaTemplateMessage.Data("keyword5", merchant.getName(), "#173177"), | |||
| new WxMaTemplateMessage.Data("keyword6", EnumOrderStatus.getEnum(order.getOrderStatus()).getMessage(), "#173177"))) | |||
| .templateId(msg.getTemplateId()) | |||
| .emphasisKeyword("keyword1.DATA") | |||
| .build(); | |||
| //templateMessage.addData( new WxMaTemplateMessage.Data("keyword1", "339208499", "#173177")); | |||
| try { | |||
| wxMaService.getMsgService().sendTemplateMsg(templateMessage); | |||
| } catch (WxErrorException e) { | |||
| logger.error("支付通知发送失败: " + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.TEMPLATE_SEND_FAILED); | |||
| } | |||
| } | |||
| } | |||
| @@ -13,6 +13,7 @@ import com.simple.domain.po.*; | |||
| import com.simple.enums.EnumPayDomain; | |||
| import com.simple.enums.EnumProfitSharingReceiverType; | |||
| import com.simple.enums.EnumProfitSharingStatus; | |||
| import com.simple.enums.EnumProfitSharingType; | |||
| import com.simple.exception.MallinkException; | |||
| import com.simple.mapper.*; | |||
| import com.simple.pay.WxPayment; | |||
| @@ -141,16 +142,14 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||
| try { | |||
| WxAppinfo subAppInfo = getAppinfo(wxPayOrder); | |||
| WxPayAccount payAccount = wxPayAccountMapper.selectByPrimaryKey(subAppInfo.getPayId()); | |||
| //WxPayAccount mainPayAccount = wxPayAccountMapper.selectByPrimaryKey(new Long(EnumPayDomain.PAY_DOMAIN_MASTER_ACCOUNT_ID.getCode())); | |||
| //WxAppinfo mainAppInfo = wxAppinfoMapper.selectByPrimaryKey(new Long(EnumPayDomain.PAY_DOMAIN_MASTER_APPINFO_ID.getCode())); | |||
| WxAppinfo appInfo = getAppinfo(wxPayOrder); | |||
| WxPayAccount payAccount = wxPayAccountMapper.selectByPrimaryKey(appInfo.getPayId()); | |||
| WxOrder wxOrder = wxOrderMapper.selectByPrimaryKey(wxPayOrder.getOrderId()); | |||
| //是否已创建分账订单 | |||
| WxProfitSharingOrder record = new WxProfitSharingOrder(); | |||
| record.setOrderId(wxPayOrder.getId().toString()); | |||
| record.setOrderId(wxPayOrder.getId()); | |||
| record = wxProfitSharingOrderMapper.selectOne(record); | |||
| if (record == null) { | |||
| //创建分账订单 | |||
| @@ -159,9 +158,9 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||
| record.setId(idworker.nextId()); | |||
| record.setTenantId(wxPayOrder.getTenantId()); | |||
| record.setTransactionId(wxPayOrder.getTransactionId()); | |||
| record.setOrderId(wxPayOrder.getId().toString()); | |||
| record.setOrderId(wxPayOrder.getId()); | |||
| record.setPayAmount(wxPayOrder.getPayAmount()); | |||
| record.setMerchantId(wxOrder.getMerchantId().toString()); | |||
| record.setMerchantId(wxOrder.getMerchantId()); | |||
| record.setCreateTime(currentDate); | |||
| record.setUpdateTime(currentDate); | |||
| record.setPayTimeStart(currentDate); | |||
| @@ -172,20 +171,18 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||
| //分账提交 | |||
| WxProfitSharingP wxProfitSharingP = new WxProfitSharingP(); | |||
| //wxProfitSharingP.setAppid(mainAppInfo.getAppId()); | |||
| //wxProfitSharingP.setMch_id(mainPayAccount.getMchId()); | |||
| wxProfitSharingP.setAppid(subAppInfo.getAppId()); | |||
| wxProfitSharingP.setAppid(appInfo.getParentAppId()); | |||
| wxProfitSharingP.setMch_id(payAccount.getMchId()); | |||
| wxProfitSharingP.setSub_appid(subAppInfo.getAppId()); | |||
| wxProfitSharingP.setSub_mch_id(payAccount.getMchId()); | |||
| wxProfitSharingP.setSub_appid(appInfo.getAppId()); | |||
| wxProfitSharingP.setSub_mch_id(payAccount.getSubMchId()); | |||
| wxProfitSharingP.setNonce_str(Utility.generate32UUID()); | |||
| wxProfitSharingP.setTransaction_id(wxPayOrder.getTransactionId()); | |||
| wxProfitSharingP.setOut_trade_no(record.getId().toString()); | |||
| //添加分账接受方 | |||
| WxProfitSharingReceiver wxProfitSharingReceiver = new WxProfitSharingReceiver(); | |||
| wxProfitSharingReceiver.setMerchantId(wxOrder.getMerchantId().toString()); | |||
| wxProfitSharingReceiver.setSharingType(1); | |||
| wxProfitSharingReceiver.setMerchantId(wxOrder.getMerchantId()); | |||
| wxProfitSharingReceiver.setSharingType(EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT.getCode()); | |||
| List<WxProfitSharingReceiver> wxProfitSharingReceiverList = wxProfitSharingReceiverMapper.findList(wxProfitSharingReceiver); | |||
| if (wxProfitSharingReceiverList.size()<=0 || wxProfitSharingReceiverList.size() > 50) { | |||
| throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID.getCode(), ErrorCode.PROFIT_SHARING_RECEIVER_INVALID.getMessage()); | |||
| @@ -197,7 +194,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||
| Date currentDate = new Date(); | |||
| JSONObject jo = new JSONObject(); | |||
| jo.put("type",EnumProfitSharingReceiverType.getEnum(receiver.getReceiverType()).getMessage()); | |||
| jo.put("acount",receiver.getReceiverAccount()); | |||
| jo.put("account",receiver.getReceiverAccount()); | |||
| jo.put("amount",record.getPayAmount()); //temp: sharing all money with only owner | |||
| jo.put("description",receiver.getReceiverComments()); | |||
| receivers.add(jo); | |||
| @@ -205,8 +202,8 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||
| WxProfitSharingResult result = new WxProfitSharingResult(); | |||
| result.setId(idworker.nextId()); | |||
| result.setSharingOrderId(record.getSharingOrderId()); | |||
| result.setSharingReceiverId(receiver.getId().toString()); | |||
| result.setSharingOrderId(record.getId()); | |||
| result.setSharingReceiverId(receiver.getId()); | |||
| result.setCreateTime(currentDate); | |||
| result.setUpdateTime(currentDate); | |||
| resultList.add(result); | |||
| @@ -238,15 +235,13 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||
| return new ResultData(ErrorCode.PROFIT_SHARING_APPLY_FAILED.getCode(), returnMap.get("result_msg")); | |||
| } | |||
| record.setSharingOrderId(returnMap.get("order_id")); | |||
| record.setSharingOrderNo(returnMap.get("order_id")); | |||
| record.setSharingStatus(EnumProfitSharingStatus.PROFIT_SHARING_ACCEPTED.getCode()); | |||
| record.setUpdateTime(new Date()); | |||
| wxProfitSharingOrderMapper.updateByPrimaryKey(record); | |||
| wxProfitSharingResultMapper.insertList(resultList); | |||
| return new ResultData(returnMap); | |||
| } 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()); | |||
| } | |||
| @@ -257,23 +252,19 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||
| WxProfitSharingOrder record = new WxProfitSharingOrder(); | |||
| try { | |||
| WxAppinfo subAppInfo = getAppinfo(wxPayOrder); | |||
| WxPayAccount payAccount = wxPayAccountMapper.selectByPrimaryKey(subAppInfo.getPayId()); | |||
| //WxPayAccount mainPayAccount = wxPayAccountMapper.selectByPrimaryKey(new Long(EnumPayDomain.PAY_DOMAIN_MASTER_ACCOUNT_ID.getCode())); | |||
| WxOrder wxOrder = wxOrderMapper.selectByPrimaryKey(wxPayOrder.getOrderId()); | |||
| WxAppinfo appInfo = getAppinfo(wxPayOrder); | |||
| WxPayAccount payAccount = wxPayAccountMapper.selectByPrimaryKey(appInfo.getPayId()); | |||
| //是否已创建分账订单 | |||
| record.setOrderId(wxPayOrder.getId().toString()); | |||
| record.setOrderId(wxPayOrder.getId()); | |||
| record = wxProfitSharingOrderMapper.selectOne(record); | |||
| if (record == null) | |||
| throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND.getCode(), ErrorCode.ORDER_IS_NOT_FIND.getMessage()); | |||
| //分账提交 | |||
| WxProfitSharingQueryP wxProfitSharingQueryP = new WxProfitSharingQueryP(); | |||
| //wxProfitSharingP.setMch_id(mainPayAccount.getMchId()); | |||
| //分账查询提交 | |||
| WxProfitSharingQueryP wxProfitSharingQueryP = new WxProfitSharingQueryP();; | |||
| wxProfitSharingQueryP.setMch_id(payAccount.getMchId()); | |||
| wxProfitSharingQueryP.setSub_mch_id(payAccount.getMchId()); | |||
| wxProfitSharingQueryP.setSub_mch_id(payAccount.getSubMchId()); | |||
| wxProfitSharingQueryP.setNonce_str(Utility.generate32UUID()); | |||
| wxProfitSharingQueryP.setTransaction_id(wxPayOrder.getTransactionId()); | |||
| wxProfitSharingQueryP.setOut_trade_no(record.getId().toString()); | |||
| @@ -309,7 +300,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||
| JSONArray jReceivers = JSONArray.parseArray(receivers); | |||
| WxProfitSharingResult result = new WxProfitSharingResult(); | |||
| result.setSharingOrderId(record.getId().toString()); | |||
| result.setSharingOrderId(record.getId()); | |||
| List <WxProfitSharingResult> wxProfitSharingResultList = wxProfitSharingResultMapper.findList(result); | |||
| @@ -339,9 +330,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||
| return new ResultData(returnMap); | |||
| } catch (RuntimeException e) { | |||
| 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()); | |||
| } | |||
| } | |||
| @@ -1,21 +1,57 @@ | |||
| package com.simple.service.impl; | |||
| import java.util.*; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.simple.common.ErrorCode; | |||
| import com.simple.common.ResultData; | |||
| import com.simple.domain.po.WxAppinfo; | |||
| import com.simple.domain.po.WxMerchant; | |||
| import com.simple.domain.po.WxPayAccount; | |||
| import com.simple.domain.po.WxProfitSharingReceiver; | |||
| import com.simple.enums.EnumAppType; | |||
| import com.simple.enums.EnumProfitSharingReceiverType; | |||
| import com.simple.enums.EnumProfitSharingStatus; | |||
| import com.simple.enums.EnumProfitSharingType; | |||
| import com.simple.mapper.WxAppinfoMapper; | |||
| import com.simple.mapper.WxPayAccountMapper; | |||
| import com.simple.mapper.WxProfitSharingReceiverMapper; | |||
| import com.simple.pay.WxPayment; | |||
| import com.simple.pay.WxProfitSharing; | |||
| import com.simple.pay.WxProfitSharingP; | |||
| import com.simple.pay.WxProfitSharingReceiverP; | |||
| import com.simple.service.WxProfitSharingReceiverService; | |||
| import com.simple.utils.BeanUtils; | |||
| import com.simple.utils.Utility; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import com.simple.common.IdWorker; | |||
| @Service | |||
| public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiverService { | |||
| @Autowired | |||
| WxProfitSharingReceiverMapper wxProfitSharingReceiverMapper; | |||
| final JSONObject errorMap = JSON.parseObject("{" + | |||
| "\"SYSTEMERROR\":{\"detail\":\"接口返回错误\",\"reason\":\"系统超时\",\"resolution\":\"系统异常,请用相同参数重新调用\"}," + | |||
| "\"PARAM_ERROR\":{\"detail\":\"参数错误\\t\",\"reason\":\"请求参数未按指引进行填写\",\"resolution\":\"请求参数错误,请重新检查再调用分账接口\"}," + | |||
| "\"INVALID_REQUEST\":{\"detail\":\"请求不合法\",\"reason\":\"参数中APPID或MCHID不存在等 \",\"resolution\":\"请重新检查再调用分账接口\"}," + | |||
| "\"OPENID_MISMATCH \":{\"detail\":\"OPENID错误\",\"reason\":\"OPENID与APPID不匹配\",\"resolution\":\"请检查OPENID是否正确\"}," + | |||
| "\"FREQUENCY_LIMITED \":{\"detail\":\"频率限制\",\"reason\":\"请求过多被频率限制\",\"resolution\":\"该笔请求未受理,请降低频率后原单重试\"}," + | |||
| "\"NOAUTH \":{\"detail\":\"无分账权限\",\"reason\":\"未开通分账权限\",\"resolution\":\"请先开通分账\"}," + | |||
| "\"USER_NOTEXIST\":{\"detail\":\"分账接受方不存在\",\"reason\":\"分账接受方不存在\",\"resolution\":\"请确认分账接收方类型或者账号无误后重试\"}}"); | |||
| @Autowired | |||
| WxProfitSharingReceiverMapper wxProfitSharingReceiverMapper; | |||
| @Autowired | |||
| WxAppinfoMapper wxAppinfoMapper; | |||
| @Autowired | |||
| WxPayAccountMapper wxPayAccountMapper; | |||
| @Override | |||
| public PageInfo<WxProfitSharingReceiver> listAsPage(WxProfitSharingReceiver record, Integer pageIndex, Integer pageSize) { | |||
| @@ -43,12 +79,130 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv | |||
| public void deleteById(Long id) { | |||
| wxProfitSharingReceiverMapper.deleteByPrimaryKey(id); | |||
| } | |||
| @Override | |||
| public ResultData addReceiver(WxMerchant merchant, WxProfitSharingReceiver receiver) { | |||
| WxAppinfo appInfo = new WxAppinfo(); | |||
| appInfo.setTenantId(merchant.getTenantId()); | |||
| appInfo.setType(EnumAppType.C.getCode()); | |||
| appInfo = wxAppinfoMapper.findList(appInfo).get(0); | |||
| WxPayAccount payAccount = wxPayAccountMapper.selectByPrimaryKey(appInfo.getPayId()); | |||
| receiver.setMerchantId(merchant.getId()); | |||
| receiver.setSharingType(EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT.getCode()); | |||
| receiver.setId(IdWorker.get().nextId()); | |||
| receiver.setCreateTime(new Date()); | |||
| receiver.setUpdateTime(new Date()); | |||
| //passed from uplevel | |||
| //receiver.setReceiverAccount(receiverParam.getReceiverAccount()); | |||
| //receiver.setReceiverComments(receiverParam.getReceiverComments()); | |||
| //receiver.setReceiverType(receiverParam.getReceiverType()); | |||
| //receiver.setTrueName(receiverParam.getTrueName()); | |||
| //添加分账账户 | |||
| WxProfitSharingReceiverP wxProfitSharingReceiverP = new WxProfitSharingReceiverP(); | |||
| wxProfitSharingReceiverP.setAppid(appInfo.getParentAppId()); | |||
| wxProfitSharingReceiverP.setMch_id(payAccount.getMchId()); | |||
| wxProfitSharingReceiverP.setSub_appid(appInfo.getAppId()); | |||
| wxProfitSharingReceiverP.setSub_mch_id(payAccount.getSubMchId()); | |||
| wxProfitSharingReceiverP.setNonce_str(Utility.generate32UUID()); | |||
| JSONObject receiverJSON = new JSONObject(); | |||
| receiverJSON.put("type",EnumProfitSharingReceiverType.getEnum(receiver.getReceiverType()).getMessage()); | |||
| receiverJSON.put("account",receiver.getReceiverAccount()); | |||
| receiverJSON.put("name",receiver.getTrueName()); | |||
| wxProfitSharingReceiverP.setReceiver(receiverJSON.toJSONString()); | |||
| String response; | |||
| try { | |||
| wxProfitSharingReceiverP.setSign(WxPayment.createSign(BeanUtils.toStringMap(wxProfitSharingReceiverP), payAccount.getApiKey())); | |||
| response = WxProfitSharing.addReceiver(BeanUtils.toStringMap(wxProfitSharingReceiverP)); | |||
| }catch (Exception e) { | |||
| return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED, e.getMessage()); | |||
| } | |||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||
| String return_code = returnMap.get("return_code"); | |||
| if (!"SUCCESS".equals(return_code)) { | |||
| return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getCode(), returnMap.get("return_msg")); | |||
| } | |||
| if (!WxPayment.verifyNotify(returnMap,payAccount.getApiKey())){ | |||
| return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getCode(), ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getMessage()); | |||
| } | |||
| String result_code = returnMap.get("result_code"); | |||
| if (!"SUCCESS".equals(result_code)) { | |||
| return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getCode(), returnMap.get("result_msg")); | |||
| } | |||
| wxProfitSharingReceiverMapper.insertSelective(receiver); | |||
| return new ResultData(returnMap); | |||
| } | |||
| @Override | |||
| public ResultData delReceiver(WxMerchant merchant, WxProfitSharingReceiver receiver) { | |||
| WxAppinfo appInfo = new WxAppinfo(); | |||
| appInfo.setTenantId(merchant.getTenantId()); | |||
| appInfo.setType(EnumAppType.C.getCode()); | |||
| appInfo = wxAppinfoMapper.findList(appInfo).get(0); | |||
| WxPayAccount payAccount = wxPayAccountMapper.selectByPrimaryKey(appInfo.getPayId()); | |||
| receiver.setMerchantId(merchant.getId()); | |||
| receiver.setSharingType(EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT.getCode()); | |||
| //receiver.setReceiverAccount(receiverParam.getReceiverAccount()); | |||
| //receiver.setReceiverType(receiverParam.getReceiverType()); | |||
| receiver = wxProfitSharingReceiverMapper.selectOne(receiver); | |||
| if (receiver == null) | |||
| return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getCode(), ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getMessage()); | |||
| //删除分账账户 | |||
| WxProfitSharingReceiverP wxProfitSharingReceiverP = new WxProfitSharingReceiverP(); | |||
| wxProfitSharingReceiverP.setAppid(appInfo.getParentAppId()); | |||
| wxProfitSharingReceiverP.setMch_id(payAccount.getMchId()); | |||
| wxProfitSharingReceiverP.setSub_appid(appInfo.getAppId()); | |||
| wxProfitSharingReceiverP.setSub_mch_id(payAccount.getSubMchId()); | |||
| wxProfitSharingReceiverP.setNonce_str(Utility.generate32UUID()); | |||
| JSONObject receiverJSON = new JSONObject(); | |||
| receiverJSON.put("type",EnumProfitSharingReceiverType.getEnum(receiver.getReceiverType()).getMessage()); | |||
| receiverJSON.put("account",receiver.getReceiverAccount()); | |||
| wxProfitSharingReceiverP.setReceiver(receiverJSON.toJSONString()); | |||
| String response; | |||
| try { | |||
| wxProfitSharingReceiverP.setSign(WxPayment.createSign(BeanUtils.toStringMap(wxProfitSharingReceiverP), payAccount.getApiKey())); | |||
| response = WxProfitSharing.addReceiver(BeanUtils.toStringMap(wxProfitSharingReceiverP)); | |||
| }catch (Exception e) { | |||
| return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED, e.getMessage()); | |||
| } | |||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||
| String return_code = returnMap.get("return_code"); | |||
| if (!"SUCCESS".equals(return_code)) { | |||
| return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getCode(), returnMap.get("return_msg")); | |||
| } | |||
| if (!WxPayment.verifyNotify(returnMap,payAccount.getApiKey())){ | |||
| return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getCode(), ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getMessage()); | |||
| } | |||
| String result_code = returnMap.get("result_code"); | |||
| if (!"SUCCESS".equals(result_code)) { | |||
| return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getCode(), returnMap.get("result_msg")); | |||
| } | |||
| wxProfitSharingReceiverMapper.deleteByPrimaryKey(receiver); | |||
| return new ResultData(returnMap); | |||
| } | |||
| } | |||
| @@ -10,14 +10,13 @@ import com.simple.common.ErrorCode; | |||
| import com.simple.common.Result; | |||
| import com.simple.common.ResultData; | |||
| import com.simple.domain.po.*; | |||
| import com.simple.enums.EnumOrderStatus; | |||
| import com.simple.enums.EnumPayWay; | |||
| import com.simple.enums.EnumRefundStatus; | |||
| import com.simple.enums.*; | |||
| import com.simple.exception.MallinkException; | |||
| import com.simple.mapper.*; | |||
| import com.simple.pay.WxPay; | |||
| import com.simple.pay.WxPayment; | |||
| import com.simple.pay.WxRefundOrderP; | |||
| import com.simple.pay.WxRefundOrderSP; | |||
| import com.simple.service.WxOrderService; | |||
| import com.simple.service.WxRefundOrderService; | |||
| import com.simple.utils.BeanUtils; | |||
| @@ -53,6 +52,25 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||
| @Autowired | |||
| WxOrderService wxOrderService; | |||
| @Autowired | |||
| WxCouponOrderMapper wxCouponOrderMapper; | |||
| @Autowired | |||
| WxMerchantBUserMapper wxMerchantBUserMapper; | |||
| @Autowired | |||
| WxTemplateMsgMapper wxTemplateMsgMapper; | |||
| @Autowired | |||
| WxCouponMapper wxCouponMapper; | |||
| @Autowired | |||
| WxMerchantMapper wxMerchantMapper; | |||
| @Autowired | |||
| WxCUserMapper wxCUserMapper; | |||
| JSONObject errorRefundReqMap = JSON.parseObject("{\n" + | |||
| " \"SYSTEMERROR\": {\n" + | |||
| " \"detail\": \"接口返回错误\",\n" + | |||
| @@ -210,33 +228,142 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||
| "}"); | |||
| @Override | |||
| public ResultData createRefundOrder(boolean isReal, WxAppinfo appInfo, WxRefundOrder record, WxPayOrder payOrder, EnumPayWay payWay) { | |||
| WxPayAccount payAccount = wxPayAccountMapper.selectByPrimaryKey(appInfo.getPayId()); | |||
| if (StringUtils.isBlank(payAccount.getApiKey())) { | |||
| logger.error("支付密钥为空"); | |||
| throw new MallinkException(ErrorCode.API_KEY_NOT_FOUND.getCode(), "支付密钥为空,请联系商城管理员"); | |||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||
| public ResultData createRefundOrder(boolean isReal, WxAppinfo appInfo, Long couponOrderId, EnumRefundWay refundWay, Long bUserId) { | |||
| WxCouponOrder wxCouponOrder = wxCouponOrderMapper.selectByPrimaryKey(couponOrderId); | |||
| if(wxCouponOrder == null){ | |||
| logger.error("券ID不存在:"+ couponOrderId); | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); | |||
| } | |||
| if (StringUtils.isBlank(payAccount.getCertPath())) { | |||
| logger.error("证书路径为空"); | |||
| throw new MallinkException(ErrorCode.CERT_PATH_NOT_FOUND.getCode(), "证书路径为空,请联系商城管理员"); | |||
| WxOrder wxOrder = wxOrderMapper.selectByPrimaryKey(wxCouponOrder.getOrderId()); | |||
| if (refundWay == EnumRefundWay.B) { | |||
| logger.info("B端发起退款: bUserId-" + bUserId); | |||
| if (bUserId == null || bUserId ==0 ) { | |||
| logger.error("B端用户不存在:"+ bUserId); | |||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | |||
| } | |||
| // B端用户退款检查一下商户 | |||
| WxMerchantBUser wxMerchantBUser = wxMerchantBUserMapper.selectByPrimaryKey(bUserId); | |||
| if (wxMerchantBUser == null) { | |||
| logger.error("操作员ID不存在:" + bUserId); | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_BUSER_IS_NULL); | |||
| } | |||
| if (!wxOrder.getMerchantId().equals(wxMerchantBUser.getMerchantId())) { | |||
| logger.error("券: couponMerchantId-" + wxOrder.getMerchantId() + "核销: couponMerchantId-" + wxMerchantBUser.getMerchantId()); | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_BUSER_IS_NULL); | |||
| } | |||
| } else if (refundWay == EnumRefundWay.ADMIN) { | |||
| logger.info("ADMIN端发起退款: bUserId-" + bUserId); | |||
| } else if (refundWay == EnumRefundWay.AUTO) { | |||
| logger.info("auto端发起退款"); | |||
| } else { | |||
| logger.info("自己发起退款: cUserId-" + bUserId); | |||
| } | |||
| // check 是否有退款订单 | |||
| List<WxRefundOrder> list = wxRefundOrderMapper.findList(record); | |||
| if (list.size() > 0) { | |||
| logger.error("退款订单已存在, 无法再提交退款申请"); | |||
| throw new MallinkException(ErrorCode.REFUND_ORDER_EXIST.getCode(), "退款订单已存在, 无法再提交退款申请"); | |||
| if (wxOrder.getPayment() <= 0) { | |||
| logger.error("订单支付金额小于等于0: " + wxOrder.toString()); | |||
| throw new MallinkException(ErrorCode.REFUND_PAY_ORDER_IS_ZERO); | |||
| } | |||
| // 创建退款订单 | |||
| if (wxCouponOrder.getCouponOrderStatus().equals(EnumCouponOrderStatus.COUPON_ORDER_OVER_TIME.getCode())) { | |||
| logger.error("已过期: couponOrder-" + couponOrderId); | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_OVER_TIME); | |||
| } | |||
| if (wxCouponOrder.getCouponOrderStatus().equals(EnumCouponOrderStatus.COUPON_ORDER_INVALID.getCode())) { | |||
| logger.error("已退款: couponOrder-" + couponOrderId); | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_OVER_TIME); | |||
| } | |||
| if (wxCouponOrder.getCouponOrderStatus().equals(EnumCouponOrderStatus.COUPON_ORDER_USED.getCode())) { | |||
| logger.error("已经核销过的券: couponOrder-" + couponOrderId); | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_USED); | |||
| } | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| Long id = idWorker.nextId(); | |||
| String out_refund_id = String.valueOf(id); | |||
| Long refundOrderId = idWorker.nextId(); | |||
| Date currentDate = new Date(); | |||
| record.setId(id); | |||
| // 创建 refund Order | |||
| WxOrder rOrder = new WxOrder(); | |||
| rOrder.setId(refundOrderId); | |||
| rOrder.setTenantId(appInfo.getTenantId()); | |||
| rOrder.setOrderNumber(wxOrder.getOrderNumber()); // 退款订单填写支付订单orderNumber | |||
| rOrder.setCouponId(wxOrder.getCouponId()); | |||
| rOrder.setCUserId(wxOrder.getCUserId()); | |||
| if (refundWay == EnumRefundWay.B) { | |||
| rOrder.setBUserId(bUserId); | |||
| } else if (refundWay == EnumRefundWay.AUTO) { | |||
| rOrder.setBUserId(0L); // 自动退款, 设置bUserId为0 | |||
| } else if (refundWay == EnumRefundWay.ADMIN) { | |||
| rOrder.setBUserId(1L); // ADMIN发起退款, 设置bUserId为1 | |||
| } else { | |||
| rOrder.setBUserId(2L); // 自己发起退款, 设置bUserId为2 | |||
| } | |||
| rOrder.setMerchantId(wxOrder.getMerchantId()); | |||
| rOrder.setPaymentType(EnumPayType.PAY_REFUND.getCode()); | |||
| rOrder.setPayment(wxOrder.getPayment()); | |||
| rOrder.setOrderStatus(EnumOrderStatus.ORDER_STATUS_PENDING_REFUND.getCode()); | |||
| rOrder.setCreateDate(currentDate); | |||
| rOrder.setUpdateDate(currentDate); | |||
| try { | |||
| wxOrderMapper.insertSelective(rOrder); | |||
| } catch (Exception e) { | |||
| logger.error("退款订单保存出错: " + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "退款订单保存出错"); | |||
| } | |||
| // 更改 couponOrder 状态 | |||
| wxCouponOrder.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_INVALID.getCode()); //3退款,券作废 | |||
| if (refundWay == EnumRefundWay.B) { | |||
| wxCouponOrder.setBUserId(bUserId); | |||
| } else if (refundWay == EnumRefundWay.AUTO) { | |||
| wxCouponOrder.setBUserId(0L); // 自动退款, 设置bUserId为0 | |||
| } else if (refundWay == EnumRefundWay.ADMIN) { | |||
| wxCouponOrder.setBUserId(1L); // ADMIN发起退款, 设置bUserId为1 | |||
| } else { | |||
| wxCouponOrder.setBUserId(2L); // 自己发起退款, 设置bUserId为2 | |||
| } | |||
| wxCouponOrder.setUpdateDate(currentDate); | |||
| try { | |||
| wxCouponOrderMapper.updateByPrimaryKeySelective(wxCouponOrder); | |||
| } catch (Exception e) { | |||
| logger.error("db failed: couponOrder-" + couponOrderId + ", e:" + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | |||
| } | |||
| // 查找支付订单 | |||
| WxPayOrder payOrderQ = new WxPayOrder(); | |||
| payOrderQ.setTenantId(appInfo.getTenantId()); | |||
| payOrderQ.setCUserId(wxOrder.getCUserId()); | |||
| payOrderQ.setOrderId(wxOrder.getId()); | |||
| payOrderQ.setPayOrderStatus(EnumPayStatus.PAY_WAY_SUCCESS.getCode()); | |||
| WxPayOrder payOrder = null; | |||
| List<WxPayOrder> list = wxPayOrderMapper.findList(payOrderQ); | |||
| if (list.size() > 0) { | |||
| if (list.size() > 1) { | |||
| logger.error("TODO: payOrder成功记录应该只有一条????!!!"); | |||
| } | |||
| logger.warn(""); | |||
| payOrder = list.get(0); | |||
| } | |||
| if (payOrder == null) { | |||
| logger.error("支付订单不存在(payOrder不存在)"); | |||
| return new ResultData(ErrorCode.PAY_ORDER_NOT_FOUND); | |||
| } | |||
| WxRefundOrder record = new WxRefundOrder(); | |||
| record.setPayOrderNo(String.valueOf(payOrder.getId())); | |||
| record.setOrderId(rOrder.getId()); | |||
| // 创建退款订单 | |||
| Long refundId = idWorker.nextId(); | |||
| String out_refund_id = String.valueOf(refundId); | |||
| record.setId(refundId); | |||
| record.setTenantId(appInfo.getTenantId()); | |||
| record.setCreateTime(currentDate); | |||
| record.setUpdateTime(currentDate); | |||
| // 微信内部订单号 | |||
| record.setTransactionId(payOrder.getTransactionId()); | |||
| record.setCUserId(payOrder.getCUserId()); | |||
| record.setTotalFee(payOrder.getPayAmount()); | |||
| @@ -255,71 +382,200 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||
| logger.error("退款订单数据库插入出错: " + record.toString()); | |||
| throw new MallinkException(ErrorCode.DB_FAIL); | |||
| } | |||
| // 退款申请 | |||
| String noncestr = Utility.generate32UUID(); | |||
| WxRefundOrderP wxRefundOrderP = new WxRefundOrderP(); | |||
| wxRefundOrderP.setAppid(appInfo.getAppId()); | |||
| wxRefundOrderP.setMch_id(payAccount.getMchId()); | |||
| wxRefundOrderP.setNonce_str(noncestr); | |||
| if (record.getTransactionId() != null) | |||
| wxRefundOrderP.setTransaction_id(record.getTransactionId()); | |||
| wxRefundOrderP.setOut_trade_no(record.getPayOrderNo()); | |||
| wxRefundOrderP.setOut_refund_no(out_refund_id); | |||
| wxRefundOrderP.setTotal_fee(record.getTotalFee()); | |||
| wxRefundOrderP.setRefund_fee(record.getRefundFee()); | |||
| wxRefundOrderP.setRefund_desc("B端商户退款"); | |||
| wxRefundOrderP.setNotify_url(payAccount.getNotifyUrl() + "/refund"); | |||
| WxPayAccount payAccount = wxPayAccountMapper.selectByPrimaryKey(appInfo.getPayId()); | |||
| if (StringUtils.isBlank(payAccount.getApiKey())) { | |||
| logger.error("支付密钥为空"); | |||
| throw new MallinkException(ErrorCode.API_KEY_NOT_FOUND.getCode(), "支付密钥为空,请联系商城管理员"); | |||
| } | |||
| if (StringUtils.isBlank(payAccount.getCertPath())) { | |||
| logger.error("证书路径为空"); | |||
| throw new MallinkException(ErrorCode.CERT_PATH_NOT_FOUND.getCode(), "证书路径为空,请联系商城管理员"); | |||
| } | |||
| // check 是否有退款订单 | |||
| List<WxRefundOrder> refundList = wxRefundOrderMapper.findList(record); | |||
| if (refundList.size() > 0) { | |||
| logger.error("退款订单已存在, 无法再提交退款申请"); | |||
| throw new MallinkException(ErrorCode.REFUND_ORDER_EXIST.getCode(), "退款订单已存在, 无法再提交退款申请"); | |||
| } | |||
| if (isReal) { | |||
| Map signMap = new HashMap(); | |||
| try { | |||
| signMap = BeanUtils.toStringMap(wxRefundOrderP); | |||
| } catch (Exception e) { | |||
| logger.error("退款命令生辰: " + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_CAST_ERROR.getCode(), "退款签名异常"); | |||
| } | |||
| // 实际支付 | |||
| // 向微信提交退款申请 | |||
| if (payAccount.getType() == EnumPayMode.MCH.getCode()) { | |||
| String noncestr = Utility.generate32UUID(); | |||
| WxRefundOrderP wxRefundOrderP = new WxRefundOrderP(); | |||
| wxRefundOrderP.setAppid(appInfo.getAppId()); | |||
| wxRefundOrderP.setMch_id(payAccount.getMchId()); | |||
| wxRefundOrderP.setNonce_str(noncestr); | |||
| // 微信内部订单号 | |||
| if (record.getTransactionId() != null) | |||
| wxRefundOrderP.setTransaction_id(record.getTransactionId()); | |||
| // 支付订单号 | |||
| wxRefundOrderP.setOut_trade_no(payOrder.getPayOrderNo()); | |||
| // 退款支付订单号 | |||
| wxRefundOrderP.setOut_refund_no(out_refund_id); | |||
| wxRefundOrderP.setTotal_fee(record.getTotalFee()); | |||
| wxRefundOrderP.setRefund_fee(record.getRefundFee()); | |||
| if (refundWay == EnumRefundWay.B) { | |||
| wxRefundOrderP.setRefund_desc("B端商户退款"); | |||
| } else if (refundWay == EnumRefundWay.ADMIN) { | |||
| wxRefundOrderP.setRefund_desc("管理端商户退款"); | |||
| } else if (refundWay == EnumRefundWay.AUTO) { | |||
| wxRefundOrderP.setRefund_desc("超期自动退款"); | |||
| } else { | |||
| wxRefundOrderP.setRefund_desc("用户自己退款"); | |||
| } | |||
| wxRefundOrderP.setNotify_url(payAccount.getNotifyUrl() + "/refund"); | |||
| String signAgent = WxPayment.createSign(signMap, payAccount.getApiKey()); | |||
| signMap.put("sign", signAgent); | |||
| String response = null; | |||
| try { | |||
| response = WxPay.orderRefund(signMap, payAccount.getCertPath(), payAccount.getMchId()); | |||
| } catch (Exception e) { | |||
| logger.error("退款异常: " + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.REFUND_ORDER_ERROR.getCode(), "退款异常"); | |||
| } | |||
| logger.info("微信退款订单:" + wxRefundOrderP.toString() + ", response: " + response.toString()); | |||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||
| String result_no = returnMap.get("result_code"); | |||
| String refund_id = returnMap.get("refund_id"); | |||
| // 设置 微信退款订单号 | |||
| record.setRefundId(refund_id); | |||
| record.setRefundVendor(EnumPayWay.PAY_WAY_WEAPP.getCode()); | |||
| if ("SUCCESS".equals(result_no)) { | |||
| logger.error("微信退款订单申请成功: " + returnMap.toString()); | |||
| Map signMap = null; | |||
| try { | |||
| record.setRefundOrderStatus(EnumRefundStatus.REFUND_REQ_SUCCESS.getCode()); | |||
| wxRefundOrderMapper.updateByPrimaryKey(record); | |||
| return new ResultData(Result.SUCCESS, "退款订单申请成功", returnMap); | |||
| signMap = BeanUtils.toStringMap(wxRefundOrderP); | |||
| } catch (Exception e) { | |||
| logger.error("微信退款订单更新入库出错: " + e.getMessage() + ", record: " + record.toString()); | |||
| throw new MallinkException(ErrorCode.REFUND_ORDER_ERROR); | |||
| logger.error("退款命令生辰: " + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_CAST_ERROR.getCode(), "退款签名异常"); | |||
| } | |||
| String signAgent = WxPayment.createSign(signMap, payAccount.getApiKey()); | |||
| signMap.put("sign", signAgent); | |||
| String response = null; | |||
| try { | |||
| response = WxPay.orderRefund(signMap, payAccount.getCertPath(), payAccount.getMchId()); | |||
| } catch (Exception e) { | |||
| logger.error("退款异常: " + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.REFUND_ORDER_ERROR.getCode(), "退款异常"); | |||
| } | |||
| logger.info("微信退款订单:" + wxRefundOrderP.toString() + ", response: " + response.toString()); | |||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||
| String result_no = returnMap.get("result_code"); | |||
| String refund_id = returnMap.get("refund_id"); | |||
| // 设置 微信退款订单号 | |||
| record.setRefundId(refund_id); | |||
| record.setRefundVendor(EnumPayWay.PAY_WAY_WEAPP.getCode()); | |||
| if ("SUCCESS".equals(result_no)) { | |||
| logger.error("微信退款订单申请成功: " + returnMap.toString()); | |||
| try { | |||
| record.setRefundOrderStatus(EnumRefundStatus.REFUND_REQ_SUCCESS.getCode()); | |||
| wxRefundOrderMapper.updateByPrimaryKey(record); | |||
| return new ResultData(Result.SUCCESS, "退款订单申请成功", returnMap); | |||
| } catch (Exception e) { | |||
| logger.error("微信退款订单更新入库出错: " + e.getMessage() + ", record: " + record.toString()); | |||
| throw new MallinkException(ErrorCode.REFUND_ORDER_ERROR); | |||
| } | |||
| } else { | |||
| logger.error("微信退款订单申请失败: " + returnMap.toString()); | |||
| try { | |||
| record.setRefundOrderStatus(EnumRefundStatus.REFUND_REQ_FAIL.getCode()); | |||
| wxRefundOrderMapper.updateByPrimaryKey(record); | |||
| JSONObject errObj = errorRefundReqMap.getJSONObject(result_no); | |||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), errObj.toJSONString(), returnMap); | |||
| } catch(Exception e) { | |||
| logger.error("微信退款订单更新入库出错: " + e.getMessage() + ", record: " + record.toString()); | |||
| throw new MallinkException(ErrorCode.REFUND_ORDER_ERROR); | |||
| } | |||
| } | |||
| } else { | |||
| logger.error("微信退款订单申请失败: " + returnMap.toString()); | |||
| String noncestr = Utility.generate32UUID(); | |||
| WxRefundOrderSP wxRefundOrderSP = new WxRefundOrderSP(); | |||
| wxRefundOrderSP.setAppid(appInfo.getParentAppId()); | |||
| wxRefundOrderSP.setSub_appid(appInfo.getAppId()); | |||
| wxRefundOrderSP.setMch_id(payAccount.getMchId()); | |||
| wxRefundOrderSP.setSub_mch_id(payAccount.getSubMchId()); | |||
| wxRefundOrderSP.setNonce_str(noncestr); | |||
| // 微信内部订单号 | |||
| if (record.getTransactionId() != null) | |||
| wxRefundOrderSP.setTransaction_id(record.getTransactionId()); | |||
| // 支付订单号 | |||
| wxRefundOrderSP.setOut_trade_no(payOrder.getPayOrderNo()); | |||
| // 退款支付订单号 | |||
| wxRefundOrderSP.setOut_refund_no(out_refund_id); | |||
| wxRefundOrderSP.setTotal_fee(record.getTotalFee()); | |||
| wxRefundOrderSP.setRefund_fee(record.getRefundFee()); | |||
| if (refundWay == EnumRefundWay.B) { | |||
| wxRefundOrderSP.setRefund_desc("B端商户退款"); | |||
| } else if (refundWay == EnumRefundWay.ADMIN) { | |||
| wxRefundOrderSP.setRefund_desc("管理端商户退款"); | |||
| } else if (refundWay == EnumRefundWay.AUTO) { | |||
| wxRefundOrderSP.setRefund_desc("超期自动退款"); | |||
| } else { | |||
| wxRefundOrderSP.setRefund_desc("用户自己退款"); | |||
| } | |||
| wxRefundOrderSP.setNotify_url(payAccount.getNotifyUrl() + "/refund"); | |||
| Map signMap = null; | |||
| try { | |||
| signMap = BeanUtils.toStringMap(wxRefundOrderSP); | |||
| } catch (Exception e) { | |||
| logger.error("退款命令生辰: " + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_CAST_ERROR.getCode(), "退款签名异常"); | |||
| } | |||
| String signAgent = WxPayment.createSign(signMap, payAccount.getApiKey()); | |||
| signMap.put("sign", signAgent); | |||
| String response = null; | |||
| try { | |||
| record.setRefundOrderStatus(EnumRefundStatus.REFUND_REQ_FAIL.getCode()); | |||
| wxRefundOrderMapper.updateByPrimaryKey(record); | |||
| JSONObject errObj = errorRefundReqMap.getJSONObject(result_no); | |||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), errObj.toJSONString(), returnMap); | |||
| } catch(Exception e) { | |||
| logger.error("微信退款订单更新入库出错: " + e.getMessage() + ", record: " + record.toString()); | |||
| throw new MallinkException(ErrorCode.REFUND_ORDER_ERROR); | |||
| response = WxPay.orderRefund(signMap, payAccount.getCertPath(), payAccount.getMchId()); | |||
| } catch (Exception e) { | |||
| logger.error("退款异常: " + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.REFUND_ORDER_ERROR.getCode(), "退款异常"); | |||
| } | |||
| logger.info("微信退款订单:" + wxRefundOrderSP.toString() + ", response: " + response.toString()); | |||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||
| String result_no = returnMap.get("result_code"); | |||
| String refund_id = returnMap.get("refund_id"); | |||
| // 设置 微信退款订单号 | |||
| record.setRefundId(refund_id); | |||
| record.setRefundVendor(EnumPayWay.PAY_WAY_WEAPP.getCode()); | |||
| if ("SUCCESS".equals(result_no)) { | |||
| logger.error("微信退款订单申请成功: " + returnMap.toString()); | |||
| try { | |||
| record.setRefundOrderStatus(EnumRefundStatus.REFUND_REQ_SUCCESS.getCode()); | |||
| wxRefundOrderMapper.updateByPrimaryKey(record); | |||
| return new ResultData(Result.SUCCESS, "退款订单申请成功", returnMap); | |||
| } catch (Exception e) { | |||
| logger.error("微信退款订单更新入库出错: " + e.getMessage() + ", record: " + record.toString()); | |||
| throw new MallinkException(ErrorCode.REFUND_ORDER_ERROR); | |||
| } | |||
| } else { | |||
| logger.error("微信退款订单申请失败: " + returnMap.toString()); | |||
| try { | |||
| record.setRefundOrderStatus(EnumRefundStatus.REFUND_REQ_FAIL.getCode()); | |||
| wxRefundOrderMapper.updateByPrimaryKey(record); | |||
| JSONObject errObj = errorRefundReqMap.getJSONObject(result_no); | |||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), errObj.toJSONString(), returnMap); | |||
| } catch(Exception e) { | |||
| logger.error("微信退款订单更新入库出错: " + e.getMessage() + ", record: " + record.toString()); | |||
| throw new MallinkException(ErrorCode.REFUND_ORDER_ERROR); | |||
| } | |||
| } | |||
| } | |||
| } else { | |||
| // 虚拟支付 | |||
| // 向微信提交退款申请 | |||
| String noncestr = Utility.generate32UUID(); | |||
| WxRefundOrderP wxRefundOrderP = new WxRefundOrderP(); | |||
| wxRefundOrderP.setAppid(appInfo.getAppId()); | |||
| wxRefundOrderP.setMch_id(payAccount.getMchId()); | |||
| wxRefundOrderP.setNonce_str(noncestr); | |||
| // 微信内部订单号 | |||
| if (record.getTransactionId() != null) | |||
| wxRefundOrderP.setTransaction_id(record.getTransactionId()); | |||
| // 支付订单号 | |||
| wxRefundOrderP.setOut_trade_no(payOrder.getPayOrderNo()); | |||
| // 退款支付订单号 | |||
| wxRefundOrderP.setOut_refund_no(out_refund_id); | |||
| wxRefundOrderP.setTotal_fee(record.getTotalFee()); | |||
| wxRefundOrderP.setRefund_fee(record.getRefundFee()); | |||
| if (refundWay == EnumRefundWay.B) { | |||
| wxRefundOrderP.setRefund_desc("B端商户退款"); | |||
| } else if (refundWay == EnumRefundWay.ADMIN) { | |||
| wxRefundOrderP.setRefund_desc("管理端商户退款"); | |||
| } else if (refundWay == EnumRefundWay.AUTO) { | |||
| wxRefundOrderP.setRefund_desc("超期自动退款"); | |||
| } else { | |||
| wxRefundOrderP.setRefund_desc("用户自己退款"); | |||
| } | |||
| wxRefundOrderP.setNotify_url(payAccount.getNotifyUrl() + "/refund"); | |||
| Map returnMap = null; | |||
| try { | |||
| returnMap = BeanUtils.toStringMap(wxRefundOrderP); | |||
| @@ -346,19 +602,37 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||
| @Override | |||
| public ResultData queryRefundOrder(WxAppinfo appInfo, WxRefundOrder record) { | |||
| WxPayAccount payAccount = wxPayAccountMapper.selectByPrimaryKey(appInfo.getPayId()); | |||
| Map<String, String> paramMap = WxPayment.buildWeappRefundQueryMap(appInfo.getAppId(), payAccount.getMchId(), | |||
| record.getTransactionId(), record.getPayOrderNo(), String.valueOf(record.getId()), record.getRefundId(), payAccount.getApiKey()); | |||
| String response = WxPay.orderRefundQuery(paramMap); | |||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||
| String result_no = returnMap.get("result_code"); | |||
| if ("SUCCESS".equals(result_no)) { | |||
| String refund_id = returnMap.get("refund_id"); | |||
| return new ResultData(Result.SUCCESS, "退款", returnMap); | |||
| if (payAccount.getType() == EnumPayMode.MCH.getCode()) { | |||
| Map<String, String> paramMap = WxPayment.buildWeappRefundQueryMap( | |||
| appInfo.getAppId(), payAccount.getMchId(), | |||
| record.getTransactionId(), record.getPayOrderNo(), String.valueOf(record.getId()), | |||
| record.getRefundId(), payAccount.getApiKey()); | |||
| String response = WxPay.orderRefundQuery(paramMap); | |||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||
| String result_no = returnMap.get("result_code"); | |||
| if ("SUCCESS".equals(result_no)) { | |||
| String refund_id = returnMap.get("refund_id"); | |||
| return new ResultData(Result.SUCCESS, "退款", returnMap); | |||
| } else { | |||
| wxRefundOrderMapper.updateByPrimaryKey(record); | |||
| JSONObject errObj = errorRefundReqMap.getJSONObject(result_no); | |||
| return new ResultData(ErrorCode.REFUND_ORDER_ERROR.getCode(), errObj.toJSONString(), returnMap); | |||
| } | |||
| } else { | |||
| wxRefundOrderMapper.updateByPrimaryKey(record); | |||
| JSONObject errObj = errorRefundReqMap.getJSONObject(result_no); | |||
| return new ResultData(ErrorCode.REFUND_ORDER_ERROR.getCode(), errObj.toJSONString(), returnMap); | |||
| Map<String, String> paramMap = WxPayment.buildSWeappRefundQueryMap( | |||
| appInfo.getParentAppId(), appInfo.getAppId(), payAccount.getMchId(), payAccount.getSubMchId(), | |||
| record.getTransactionId(), record.getPayOrderNo(), String.valueOf(record.getId()), record.getRefundId(), payAccount.getApiKey()); | |||
| String response = WxPay.orderRefundQuery(paramMap); | |||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||
| String result_no = returnMap.get("result_code"); | |||
| if ("SUCCESS".equals(result_no)) { | |||
| String refund_id = returnMap.get("refund_id"); | |||
| return new ResultData(Result.SUCCESS, "退款", returnMap); | |||
| } else { | |||
| wxRefundOrderMapper.updateByPrimaryKey(record); | |||
| JSONObject errObj = errorRefundReqMap.getJSONObject(result_no); | |||
| return new ResultData(ErrorCode.REFUND_ORDER_ERROR.getCode(), errObj.toJSONString(), returnMap); | |||
| } | |||
| } | |||
| } | |||
| @@ -371,97 +645,194 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||
| @Override | |||
| public String notify(Map<String, String> paramMap, EnumPayWay payWay) { | |||
| // how to get wechatAppId, wechatMchId, partnerKey | |||
| String wechatAppId = paramMap.get("appid"); | |||
| String wechatMchId = paramMap.get("mch_id"); | |||
| WxAppinfo appinfo = wxAppinfoMapper.findByAppId(wechatAppId); | |||
| if (appinfo == null) { | |||
| logger.error("未找到appid信息:"+wechatAppId); | |||
| throw new MallinkException(ErrorCode.APP_ID_NOT_FOUND); | |||
| } | |||
| WxPayAccount payAccount = wxPayAccountMapper.selectByPrimaryKey(appinfo.getPayId()); | |||
| if (payAccount == null) { | |||
| logger.error("未找到mch_id信息:"+wechatMchId); | |||
| throw new MallinkException(ErrorCode.MCH_INFO_NOT_FOUND); | |||
| } | |||
| if (wechatMchId != payAccount.getMchId()) { | |||
| logger.error("mch_id不对应:"+wechatMchId + ",account:" + payAccount.getMchId()); | |||
| throw new MallinkException(ErrorCode.MCH_INFO_NOT_EQUAL); | |||
| } | |||
| String partnerKey = payAccount.getApiKey(); | |||
| try { | |||
| if (payWay == EnumPayWay.PAY_WAY_WEAPP) { | |||
| boolean signVerified = false; | |||
| // 微信支付 | |||
| signVerified = WxPayment.verifyNotify(paramMap, partnerKey); | |||
| if (!signVerified) { | |||
| logger.warn("notify order, wxpay checksign error, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR); | |||
| } | |||
| if (!"SUCCESS".equals(paramMap.get("return_code"))) { | |||
| logger.warn("notify order, wxpay status not success, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "订单状态码非SUCCESS"); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| String payOrderNo = paramMap.get("out_trade_no"); | |||
| Long payOrderId = Long.valueOf(payOrderNo); | |||
| WxPayOrder payOrder = wxPayOrderMapper.selectByPrimaryKey(payOrderId); | |||
| if (payOrder == null) { | |||
| logger.warn("notify order, wxpay check pay order not exists, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "订单不存在"); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| // 验证支付金额 | |||
| if(!paramMap.get("total_fee").equals(payOrder.getPayAmount().toString())) { | |||
| logger.warn("notify order, wxpay check total_fee is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "订单总金额不一致"); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| String refundOrderNo = paramMap.get("out_refund_no"); | |||
| Long refundOrderId = Long.valueOf(refundOrderNo); | |||
| WxRefundOrder refundOrder = wxRefundOrderMapper.selectByPrimaryKey(refundOrderId); | |||
| if (refundOrder == null) { | |||
| logger.warn("notify order, wxpay check pay order not exists, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "退款订单不存在"); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| // 验证支付金额 | |||
| if(!paramMap.get("total_fee").equals(refundOrder.getTotalFee().toString())) { | |||
| logger.warn("notify order, wxpay check total_fee is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| String appId = paramMap.get("appid"); | |||
| String subAppId = paramMap.get("sub_appid"); | |||
| String mchId = paramMap.get("mch_id"); | |||
| String subMchId = paramMap.get("sub_mch_id"); | |||
| if (StringUtils.isBlank(subAppId) && StringUtils.isBlank(subMchId)) { | |||
| // 普通商户号 | |||
| WxAppinfo appinfo = wxAppinfoMapper.findByAppId(appId); | |||
| if (appinfo == null) { | |||
| logger.error("未找到appid信息:"+appId); | |||
| throw new MallinkException(ErrorCode.APP_ID_NOT_FOUND); | |||
| } | |||
| WxPayAccount payAccount = wxPayAccountMapper.selectByPrimaryKey(appinfo.getPayId()); | |||
| if (payAccount == null) { | |||
| logger.error("未找到mch_id信息:"+mchId); | |||
| throw new MallinkException(ErrorCode.MCH_INFO_NOT_FOUND); | |||
| } | |||
| if (mchId != payAccount.getMchId()) { | |||
| logger.error("mch_id不对应:"+mchId + ",account:" + payAccount.getMchId()); | |||
| throw new MallinkException(ErrorCode.MCH_INFO_NOT_EQUAL); | |||
| } | |||
| String partnerKey = payAccount.getApiKey(); | |||
| try { | |||
| if (payWay == EnumPayWay.PAY_WAY_WEAPP) { | |||
| boolean signVerified = false; | |||
| // 微信支付 | |||
| signVerified = WxPayment.verifyNotify(paramMap, partnerKey); | |||
| if (!signVerified) { | |||
| logger.warn("notify order, wxpay checksign error, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR); | |||
| } | |||
| if (!"SUCCESS".equals(paramMap.get("return_code"))) { | |||
| logger.warn("notify order, wxpay status not success, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "订单状态码非SUCCESS"); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| String payOrderNo = paramMap.get("out_trade_no"); | |||
| Long payOrderId = Long.valueOf(payOrderNo); | |||
| WxPayOrder payOrder = wxPayOrderMapper.selectByPrimaryKey(payOrderId); | |||
| if (payOrder == null) { | |||
| logger.warn("notify order, wxpay check pay order not exists, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "支付订单不存在"); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| // 验证支付金额 | |||
| if(!paramMap.get("total_fee").equals(payOrder.getPayAmount().toString())) { | |||
| logger.warn("notify order, wxpay check total_fee is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "支付订单总金额不一致"); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| String refundIdStr = paramMap.get("out_refund_no"); | |||
| Long refundOrderId = Long.valueOf(refundIdStr); | |||
| WxRefundOrder refundOrder = wxRefundOrderMapper.selectByPrimaryKey(refundOrderId); | |||
| if (refundOrder == null) { | |||
| logger.warn("notify order, wxpay check pay order not exists, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "退款订单不存在"); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| // 验证支付金额 | |||
| if(!paramMap.get("total_fee").equals(refundOrder.getTotalFee().toString())) { | |||
| logger.warn("notify order, wxpay check total_fee is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "订单总金额不一致"); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| // 验证退款金额 | |||
| if(!paramMap.get("refund_fee").equals(refundOrder.getRefundFee().toString())) { | |||
| logger.warn("notify order, wxpay check refund_fee is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "退款总金额不一致"); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| // 处理支付成功 | |||
| handleRefundSuccess(refundOrder, paramMap.get("transaction_id"), paramMap.get("refund_id")); | |||
| logger.info("notify order, wxpay checksign success, paramMap:{}, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "订单总金额不一致"); | |||
| resultMap.put("return_code", "SUCCESS"); | |||
| resultMap.put("return_msg", "OK"); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| // 验证退款金额 | |||
| if(!paramMap.get("refund_fee").equals(refundOrder.getRefundFee().toString())) { | |||
| logger.warn("notify order, wxpay check refund_fee is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| } catch (RuntimeException e) { | |||
| logger.warn("notify order, alipay checksign error, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString() + ", e:" + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.REFUND_ORDER_ERROR); | |||
| } | |||
| } else { | |||
| // 服务号回调 | |||
| WxAppinfo appinfo = wxAppinfoMapper.findByAppId(subAppId); | |||
| if (appinfo == null) { | |||
| logger.error("未找到appid信息:"+appId); | |||
| throw new MallinkException(ErrorCode.APP_ID_NOT_FOUND); | |||
| } | |||
| WxPayAccount payAccount = wxPayAccountMapper.selectByPrimaryKey(appinfo.getPayId()); | |||
| if (payAccount == null) { | |||
| logger.error("未找到mch_id信息:"+mchId); | |||
| throw new MallinkException(ErrorCode.MCH_INFO_NOT_FOUND); | |||
| } | |||
| if (mchId != payAccount.getMchId()) { | |||
| logger.error("mch_id不对应:"+mchId + ",account:" + payAccount.getMchId()); | |||
| throw new MallinkException(ErrorCode.MCH_INFO_NOT_EQUAL); | |||
| } | |||
| String partnerKey = payAccount.getApiKey(); | |||
| try { | |||
| if (payWay == EnumPayWay.PAY_WAY_WEAPP) { | |||
| boolean signVerified = false; | |||
| // 微信支付 | |||
| signVerified = WxPayment.verifyNotify(paramMap, partnerKey); | |||
| if (!signVerified) { | |||
| logger.warn("notify order, wxpay checksign error, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR); | |||
| } | |||
| if (!"SUCCESS".equals(paramMap.get("return_code"))) { | |||
| logger.warn("notify order, wxpay status not success, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "订单状态码非SUCCESS"); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| String payOrderNo = paramMap.get("out_trade_no"); | |||
| Long payOrderId = Long.valueOf(payOrderNo); | |||
| WxPayOrder payOrder = wxPayOrderMapper.selectByPrimaryKey(payOrderId); | |||
| if (payOrder == null) { | |||
| logger.warn("notify order, wxpay check pay order not exists, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "支付订单不存在"); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| // 验证支付金额 | |||
| if(!paramMap.get("total_fee").equals(payOrder.getPayAmount().toString())) { | |||
| logger.warn("notify order, wxpay check total_fee is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "支付订单总金额不一致"); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| String refundIdStr = paramMap.get("out_refund_no"); | |||
| Long refundOrderId = Long.valueOf(refundIdStr); | |||
| WxRefundOrder refundOrder = wxRefundOrderMapper.selectByPrimaryKey(refundOrderId); | |||
| if (refundOrder == null) { | |||
| logger.warn("notify order, wxpay check pay order not exists, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "退款订单不存在"); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| // 验证支付金额 | |||
| if(!paramMap.get("total_fee").equals(refundOrder.getTotalFee().toString())) { | |||
| logger.warn("notify order, wxpay check total_fee is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "订单总金额不一致"); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| // 验证退款金额 | |||
| if(!paramMap.get("refund_fee").equals(refundOrder.getRefundFee().toString())) { | |||
| logger.warn("notify order, wxpay check refund_fee is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "退款总金额不一致"); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| // 处理支付成功 | |||
| handleRefundSuccess(refundOrder, paramMap.get("transaction_id"), paramMap.get("refund_id")); | |||
| logger.info("notify order, wxpay checksign success, paramMap:{}, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "退款总金额不一致"); | |||
| resultMap.put("return_code", "SUCCESS"); | |||
| resultMap.put("return_msg", "OK"); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| // 处理支付成功 | |||
| handleRefundSuccess(refundOrder, paramMap.get("transaction_id"), paramMap.get("refund_id")); | |||
| logger.info("notify order, wxpay checksign success, paramMap:{}, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "SUCCESS"); | |||
| resultMap.put("return_msg", "OK"); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } catch (RuntimeException e) { | |||
| logger.warn("notify order, alipay checksign error, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString() + ", e:" + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.REFUND_ORDER_ERROR); | |||
| } | |||
| } catch (RuntimeException e) { | |||
| logger.warn("notify order, alipay checksign error, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString() + ", e:" + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.REFUND_ORDER_ERROR); | |||
| } | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "FAILED"); | |||
| @@ -513,6 +884,8 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||
| logger.error(e.getMessage()); | |||
| throw new MallinkException(ErrorCode.DB_FAIL); | |||
| } | |||
| // 消息 | |||
| /* | |||
| Map<String, String> msgMap = new HashMap<>(); | |||
| try { | |||
| @@ -555,12 +928,5 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||
| public void deleteById(Long id) { | |||
| wxRefundOrderMapper.deleteByPrimaryKey(id); | |||
| } | |||
| } | |||
| @@ -0,0 +1,54 @@ | |||
| package com.simple.service.impl; | |||
| import java.util.*; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.simple.domain.po.WxTemplateMsg; | |||
| import com.simple.mapper.WxTemplateMsgMapper; | |||
| import com.simple.service.WxTemplateMsgService; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import com.simple.common.IdWorker; | |||
| @Service | |||
| public class WxTemplateMsgServiceImpl implements WxTemplateMsgService { | |||
| @Autowired | |||
| WxTemplateMsgMapper wxTemplateMsgMapper; | |||
| @Override | |||
| public PageInfo<WxTemplateMsg> listAsPage(WxTemplateMsg record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxTemplateMsgMapper.findList(record)); | |||
| } | |||
| @Override | |||
| public WxTemplateMsg getById(Long id) { | |||
| return wxTemplateMsgMapper.selectByPrimaryKey(id); | |||
| } | |||
| @Override | |||
| public void saveOrUpdate(WxTemplateMsg record) { | |||
| if (record.getId() == null) { | |||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| record.setId(idWorker.nextId()); | |||
| wxTemplateMsgMapper.insertSelective(record); | |||
| } else { | |||
| wxTemplateMsgMapper.updateByPrimaryKeySelective(record); | |||
| } | |||
| } | |||
| @Override | |||
| public void deleteById(Long id) { | |||
| wxTemplateMsgMapper.deleteByPrimaryKey(id); | |||
| } | |||
| } | |||
| @@ -0,0 +1,22 @@ | |||
| package com.simple.utils; | |||
| import cn.binarywang.wx.miniapp.api.WxMaService; | |||
| import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl; | |||
| import cn.binarywang.wx.miniapp.config.WxMaInMemoryConfig; | |||
| import com.simple.domain.po.WxAppinfo; | |||
| public class MaUtil { | |||
| static public WxMaService getWeappService(WxAppinfo appinfo) { | |||
| WxMaInMemoryConfig config = new WxMaInMemoryConfig(); | |||
| config.setAppid(appinfo.getAppId()); | |||
| config.setSecret(appinfo.getSecret()); | |||
| config.setToken(appinfo.getToken()); | |||
| config.setAesKey(appinfo.getAesKey()); | |||
| config.setMsgDataFormat(appinfo.getMsgDataFormat()); | |||
| WxMaService service = new WxMaServiceImpl(); | |||
| service.setWxMaConfig(config); | |||
| return service; | |||
| } | |||
| } | |||
| @@ -1,116 +1,102 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||
| <mapper namespace="com.simple.mapper.WxAppinfoMapper"> | |||
| <resultMap id="BaseResultMap" type="com.simple.domain.po.WxAppinfo"> | |||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||
| <result column="app_id" jdbcType="VARCHAR" property="appId" /> | |||
| <result column="name" jdbcType="VARCHAR" property="name" /> | |||
| <result column="secret" jdbcType="VARCHAR" property="secret" /> | |||
| <result column="token" jdbcType="VARCHAR" property="token" /> | |||
| <result column="aes_key" jdbcType="VARCHAR" property="aesKey" /> | |||
| <result column="msg_data_format" jdbcType="VARCHAR" property="msgDataFormat" /> | |||
| <result column="access_token" jdbcType="VARCHAR" property="accessToken" /> | |||
| <result column="last_token_time" jdbcType="TIMESTAMP" property="lastTokenTime" /> | |||
| <result column="expires_in" jdbcType="INTEGER" property="expiresIn" /> | |||
| <result column="pay_id" jdbcType="BIGINT" property="payId" /> | |||
| <result column="type" jdbcType="INTEGER" property="type" /> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`app_id`,`name`,`secret`,`token`,`aes_key`,`msg_data_format`,`access_token`,`last_token_time`,`expires_in`,`pay_id`,`type` | |||
| </sql> | |||
| <resultMap id="BaseResultMap" type="com.simple.domain.po.WxAppinfo"> | |||
| <id column="id" jdbcType="BIGINT" property="id"/> | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | |||
| <result column="app_id" jdbcType="VARCHAR" property="appId"/> | |||
| <result column="parent_app_id" jdbcType="VARCHAR" property="parentAppId"/> | |||
| <result column="name" jdbcType="VARCHAR" property="name"/> | |||
| <result column="secret" jdbcType="VARCHAR" property="secret"/> | |||
| <result column="token" jdbcType="VARCHAR" property="token"/> | |||
| <result column="aes_key" jdbcType="VARCHAR" property="aesKey"/> | |||
| <result column="msg_data_format" jdbcType="VARCHAR" property="msgDataFormat"/> | |||
| <result column="access_token" jdbcType="VARCHAR" property="accessToken"/> | |||
| <result column="last_token_time" jdbcType="TIMESTAMP" property="lastTokenTime"/> | |||
| <result column="expires_in" jdbcType="INTEGER" property="expiresIn"/> | |||
| <result column="pay_id" jdbcType="BIGINT" property="payId"/> | |||
| <result column="type" jdbcType="INTEGER" property="type"/> | |||
| </resultMap> | |||
| <sql id="dynamicWhereConditions"> | |||
| where 1 = 1 | |||
| <if test=" null != id "> | |||
| and `id` = #{id} | |||
| </if> | |||
| <if test=" null != tenantId "> | |||
| and `tenant_id` like concat('%', #{tenantId},'%') | |||
| </if> | |||
| <if test=" null != appId "> | |||
| and `app_id` like concat('%', #{appId},'%') | |||
| </if> | |||
| <if test=" null != name "> | |||
| and `name` like concat('%', #{name},'%') | |||
| </if> | |||
| <if test=" null != secret "> | |||
| and `secret` like concat('%', #{secret},'%') | |||
| </if> | |||
| <if test=" null != token "> | |||
| and `token` like concat('%', #{token},'%') | |||
| </if> | |||
| <if test=" null != aesKey "> | |||
| and `aes_key` like concat('%', #{aesKey},'%') | |||
| </if> | |||
| <if test=" null != msgDataFormat "> | |||
| and `msg_data_format` like concat('%', #{msgDataFormat},'%') | |||
| </if> | |||
| <if test=" null != accessToken "> | |||
| and `access_token` like concat('%', #{accessToken},'%') | |||
| </if> | |||
| <if test=" null != lastTokenTime "> | |||
| and `last_token_time` = #{lastTokenTime} | |||
| </if> | |||
| <if test=" null != expiresIn "> | |||
| and `expires_in` = #{expiresIn} | |||
| </if> | |||
| <if test=" null != payId "> | |||
| and `pay_id` = #{payId} | |||
| </if> | |||
| <if test=" null != type "> | |||
| and `type` = #{type} | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| #{idItem} | |||
| </foreach> | |||
| </if> | |||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`app_id`,`parent_app_id`,`name`,`secret`,`token`,`aes_key`,`msg_data_format`,`access_token`,`last_token_time`,`expires_in`,`pay_id`,`type` | |||
| </sql> | |||
| <select id="findList" parameterType="com.simple.domain.po.WxAppinfo" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns" /> from wx_appinfo | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| <select id="findByAppId" parameterType="java.lang.String" resultMap="BaseResultMap"> | |||
| SELECT * | |||
| FROM wx_appinfo | |||
| WHERE `app_id` = #{appId} | |||
| </select> | |||
| <sql id="dynamicWhereConditions"> | |||
| where 1 = 1 | |||
| <if test=" null != id "> | |||
| and `id` = #{id} | |||
| </if> | |||
| <if test=" null != tenantId "> | |||
| and `tenant_id` like concat('%', #{tenantId},'%') | |||
| </if> | |||
| <if test=" null != appId "> | |||
| and `app_id` like concat('%', #{appId},'%') | |||
| </if> | |||
| <if test=" null != parentAppId "> | |||
| and `parent_app_id` like concat('%', #{parentAppId},'%') | |||
| </if> | |||
| <if test=" null != name "> | |||
| and `name` like concat('%', #{name},'%') | |||
| </if> | |||
| <if test=" null != secret "> | |||
| and `secret` like concat('%', #{secret},'%') | |||
| </if> | |||
| <if test=" null != token "> | |||
| and `token` like concat('%', #{token},'%') | |||
| </if> | |||
| <if test=" null != aesKey "> | |||
| and `aes_key` like concat('%', #{aesKey},'%') | |||
| </if> | |||
| <if test=" null != msgDataFormat "> | |||
| and `msg_data_format` like concat('%', #{msgDataFormat},'%') | |||
| </if> | |||
| <if test=" null != accessToken "> | |||
| and `access_token` like concat('%', #{accessToken},'%') | |||
| </if> | |||
| <if test=" null != lastTokenTime "> | |||
| and `last_token_time` = #{lastTokenTime} | |||
| </if> | |||
| <if test=" null != expiresIn "> | |||
| and `expires_in` = #{expiresIn} | |||
| </if> | |||
| <if test=" null != payId "> | |||
| and `pay_id` = #{payId} | |||
| </if> | |||
| <if test=" null != type "> | |||
| and `type` = #{type} | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| #{idItem} | |||
| </foreach> | |||
| </if> | |||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | |||
| </sql> | |||
| <select id="findList" parameterType="com.simple.domain.po.WxAppinfo" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumns"/> | |||
| from wx_appinfo | |||
| <include refid="dynamicWhereConditions"/> | |||
| </select> | |||
| <select id="findByAppId" parameterType="java.lang.String" resultMap="BaseResultMap"> | |||
| SELECT * | |||
| FROM wx_appinfo | |||
| WHERE `app_id` = #{appId} | |||
| </select> | |||
| </mapper> | |||
| @@ -3,7 +3,6 @@ | |||
| <mapper namespace="com.simple.mapper.WxBusinessMapper"> | |||
| <resultMap id="BaseResultMap" type="com.simple.domain.po.WxBusiness"> | |||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||
| <result column="title" jdbcType="VARCHAR" property="title" /> | |||
| <result column="type" jdbcType="INTEGER" property="type" /> | |||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||
| @@ -11,40 +10,30 @@ | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`title`,`type`,`create_date`,`update_date` | |||
| `id`,`title`,`type`,`create_date`,`update_date` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| where 1 = 1 | |||
| <if test=" null != id "> | |||
| and `id` = #{id} | |||
| </if> | |||
| <if test=" null != tenantId "> | |||
| and `tenant_id` like concat('%', #{tenantId},'%') | |||
| </if> | |||
| and `id` = #{id} | |||
| </if> | |||
| <if test=" null != title "> | |||
| and `title` like concat('%', #{title},'%') | |||
| </if> | |||
| <if test=" null != type "> | |||
| and `type` = #{type} | |||
| and `type` = #{type} | |||
| </if> | |||
| <if test=" null != createDate "> | |||
| and `create_date` = #{createDate} | |||
| and `create_date` = #{createDate} | |||
| </if> | |||
| <if test=" null != updateDate "> | |||
| and `update_date` = #{updateDate} | |||
| and `update_date` = #{updateDate} | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| @@ -3,42 +3,32 @@ | |||
| <mapper namespace="com.simple.mapper.WxChannelMapper"> | |||
| <resultMap id="BaseResultMap" type="com.simple.domain.po.WxChannel"> | |||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||
| <result column="tenant_id" jdbcType="BIGINT" property="tenantId" /> | |||
| <result column="channel_id" jdbcType="INTEGER" property="channelId" /> | |||
| <result column="title" jdbcType="VARCHAR" property="title" /> | |||
| <result column="img" jdbcType="VARCHAR" property="img" /> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`channel_id`,`title`,`img` | |||
| `id`,`channel_id`,`title`,`img` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| where 1 = 1 | |||
| <if test=" null != id "> | |||
| and `id` = #{id} | |||
| </if> | |||
| <if test=" null != tenantId "> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| and `id` = #{id} | |||
| </if> | |||
| <if test=" null != channelId "> | |||
| and `channel_id` = #{channelId} | |||
| and `channel_id` = #{channelId} | |||
| </if> | |||
| <if test=" null != title "> | |||
| and `title` like concat('%', #{title},'%') | |||
| </if> | |||
| <if test=" null != img "> | |||
| and `img` like concat('%', #{img},'%') | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| @@ -63,7 +63,6 @@ | |||
| <if test=" null != business "> | |||
| and `business` like concat('%', #{business},'%') | |||
| </if> | |||
| <if test=" null != beginTime "> | |||
| @@ -155,8 +154,12 @@ | |||
| <update id="offExpiriedCouponChannelByValidDate"> | |||
| update wx_coupon_channel, wx_coupon c SET cc.status = 1, cc.update_date = now() | |||
| where cc.status = 0 and cc.coupon_id = c.id and c.valid_type = 1 and valid_end_date < now(); | |||
| where cc.status = 0 and cc.coupon_id = c.id and c.valid_type = 1 and valid_end_date < now() | |||
| </update> | |||
| <update id="offExpiriedCouponChannelByCouponStatus"> | |||
| update wx_coupon_channel, wx_coupon c SET cc.status = 1, cc.update_date = now() | |||
| where cc.status = 0 and cc.coupon_id = c.id and c.status = 1 | |||
| </update> | |||
| </mapper> | |||
| @@ -245,7 +245,7 @@ | |||
| select <include refid="allCUserColumns" /> | |||
| from wx_coupon_channel cc, | |||
| wx_coupon c,wx_merchant m | |||
| left join wx_merchant_shop ms on ms.merchant_id = m.id | |||
| left join wx_merchant_shop ms on ms.merchant_id = m.id and ms.is_del = 0 | |||
| left join wx_shop s on ms.shop_id = s.id | |||
| left join wx_mall_building mb on s.building = mb.id | |||
| left join wx_mall_floor mf on s.floor = mf.id | |||
| @@ -277,7 +277,7 @@ | |||
| select <include refid="allCUserColumns2" /> | |||
| from | |||
| wx_coupon c,wx_merchant m | |||
| left join wx_merchant_shop ms on ms.merchant_id = m.id | |||
| left join wx_merchant_shop ms on ms.merchant_id = m.id and ms.is_del = 0 | |||
| left join wx_shop s on ms.shop_id = s.id | |||
| left join wx_mall_building mb on s.building = mb.id | |||
| left join wx_mall_floor mf on s.floor = mf.id | |||
| @@ -151,7 +151,6 @@ | |||
| <if test="endDate != null"> | |||
| AND co.create_date < #{endDate,jdbcType=TIMESTAMP} | |||
| </if> | |||
| AND (co.coupon_order_status = '0' or co.coupon_order_status = '1') | |||
| order by co.create_date desc | |||
| </select> | |||
| @@ -253,7 +252,6 @@ | |||
| <if test="endDate != null"> | |||
| AND co.create_date < #{endDate,jdbcType=TIMESTAMP} | |||
| </if> | |||
| AND (co.coupon_order_status = '0' or co.coupon_order_status = '1') | |||
| </select> | |||
| @@ -328,7 +326,7 @@ | |||
| </resultMap> | |||
| <select id="findListOfCUser" parameterType="com.simple.domain.po.WxCouponOrder" resultMap="CVoResultMap"> | |||
| <select id="findListOfCUser" parameterType="com.simple.domain.vo.WxCouponOrderCVo" resultMap="CVoResultMap"> | |||
| select <include refid="allCUserCouponOrderListColumns" /> | |||
| from wx_coupon_order c,wx_coupon co,wx_merchant m | |||
| where 1=1 | |||
| @@ -340,6 +338,12 @@ | |||
| <if test="tenantId != null"> | |||
| and c.tenant_id = #{tenantId} | |||
| </if> | |||
| <if test="type != null"> | |||
| and co.type = #{type} | |||
| </if> | |||
| <if test="type == null"> | |||
| and co.type < 5 | |||
| </if> | |||
| <if test="couponOrderStatus != null"> | |||
| AND c.coupon_order_status = #{couponOrderStatus} | |||
| </if> | |||
| @@ -349,7 +353,7 @@ | |||
| <select id="selectDetailOfUser" parameterType="map" resultMap="CVoResultMap"> | |||
| select <include refid="allCUserCouponOrderDetailColumns" /> | |||
| from wx_coupon_order c,wx_coupon co,wx_merchant m | |||
| left join wx_merchant_shop ms on ms.merchant_id = m.id | |||
| left join wx_merchant_shop ms on ms.merchant_id = m.id and ms.is_del = 0 | |||
| left join wx_shop s on ms.shop_id = s.id | |||
| left join wx_mall_building mb on s.building = mb.id | |||
| left join wx_mall_floor mf on s.floor = mf.id | |||
| @@ -426,6 +430,83 @@ | |||
| <update id="offExpiredCouponOrderByValidDate"> | |||
| update wx_coupon_order SET coupon_order_status = 2, update_date = now() | |||
| where expired_time < now() and coupon_price = 0 and coupon_order_status = 0 | |||
| </update> | |||
| <select id="findExpiredCouponOrderByValidDate" parameterType="com.simple.domain.po.WxCouponOrder" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns" /> from wx_coupon_order | |||
| where expired_time < now() and coupon_price > 0 and coupon_order_status = 0 | |||
| </select> | |||
| <sql id="allCUserCouponOrderCarListColumns"> | |||
| c.id,c.expired_time,c.coupon_order_status,c.create_date,c.update_date,c.coupon_price, | |||
| co.cover_img,co.title,co.sub_title,co.sale_price,co.use_price,co.price,m.id as merchant_id, | |||
| m.name,json_extract(car.vendor_params,'$.id') as coupon_free_id | |||
| </sql> | |||
| <resultMap id="CCarVoResultMap" type="com.simple.domain.vo.WxCouponOrderCarCVo"> | |||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||
| <result column="tenant_id" jdbcType="BIGINT" property="tenantId" /> | |||
| <result column="coupon_id" jdbcType="BIGINT" property="couponId" /> | |||
| <result column="c_user_id" jdbcType="BIGINT" property="cUserId" /> | |||
| <result column="b_user_id" jdbcType="BIGINT" property="bUserId" /> | |||
| <result column="order_id" jdbcType="BIGINT" property="orderId" /> | |||
| <result column="expired_time" jdbcType="TIMESTAMP" property="expiredTime" /> | |||
| <result column="coupon_order_status" jdbcType="INTEGER" property="couponOrderStatus" /> | |||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | |||
| <result column="coupon_price" jdbcType="INTEGER" property="couponPrice" /> | |||
| <result column="merchant_id" jdbcType="BIGINT" property="merchantId" /> | |||
| <result column="type" jdbcType="INTEGER" property="type" /> | |||
| <result column="cover_img" jdbcType="VARCHAR" property="coverImg" /> | |||
| <result column="title" jdbcType="VARCHAR" property="title" /> | |||
| <result column="sub_title" jdbcType="VARCHAR" property="subTitle" /> | |||
| <result column="sale_price" jdbcType="INTEGER" property="salePrice" /> | |||
| <result column="use_price" jdbcType="INTEGER" property="usePrice" /> | |||
| <result column="detail" jdbcType="VARCHAR" property="detail" /> | |||
| <result column="price" jdbcType="INTEGER" property="price" /> | |||
| <result column="remark" jdbcType="VARCHAR" property="remark" /> | |||
| <result column="img_url" jdbcType="VARCHAR" property="merchantImgUrl" /> | |||
| <result column="name" jdbcType="VARCHAR" property="merchantName" /> | |||
| <result column="link_phone" jdbcType="VARCHAR" property="merchantLinkPhone" /> | |||
| <result column="status" jdbcType="VARCHAR" property="merchantStatus" /> | |||
| <result column="addr" jdbcType="VARCHAR" property="addr"/> | |||
| <result column="shop_number" jdbcType="VARCHAR" property="shopNumber"/> | |||
| <result column="building_name" jdbcType="VARCHAR" property="buildingName" /> | |||
| <result column="floor_name" jdbcType="VARCHAR" property="floorName" /> | |||
| <result column="baidu_poi" jdbcType="VARCHAR" property="baiduPoi"/> | |||
| <result column="coupon_free_id" jdbcType="INTEGER" property="couponFreeId"/> | |||
| </resultMap> | |||
| <select id="findCarListOfCUser" parameterType="com.simple.domain.vo.WxCouponOrderCarCVo" resultMap="CCarVoResultMap"> | |||
| select <include refid="allCUserCouponOrderCarListColumns" /> | |||
| from wx_coupon_order c,wx_coupon co,wx_merchant m, wx_coupon_car car | |||
| where 1=1 | |||
| and c.coupon_id = co.id | |||
| and c.coupon_id = car.id | |||
| and co.merchant_id = m.id | |||
| <if test="cUserId != null"> | |||
| and c.c_user_id = #{cUserId} | |||
| </if> | |||
| <if test="tenantId != null"> | |||
| and c.tenant_id = #{tenantId} | |||
| </if> | |||
| <if test="type != null"> | |||
| and co.type = #{type} | |||
| </if> | |||
| <if test="couponOrderStatus != null"> | |||
| AND c.coupon_order_status = #{couponOrderStatus} | |||
| </if> | |||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||
| </select> | |||
| </mapper> | |||
| </mapper> | |||
| @@ -0,0 +1,42 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||
| <mapper namespace="com.simple.mapper.WxMallApplyMapper"> | |||
| <resultMap id="BaseResultMap" type="com.simple.domain.po.WxMallApply"> | |||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||
| <result column="mall_name" jdbcType="VARCHAR" property="mallName" /> | |||
| <result column="applicant" jdbcType="VARCHAR" property="applicant" /> | |||
| <result column="phone" jdbcType="VARCHAR" property="phone" /> | |||
| <result column="apply_date" jdbcType="TIMESTAMP" property="applyDate" /> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`mall_name`,`applicant`,`phone`,`apply_date` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| where 1 = 1 | |||
| <if test=" null != id "> and `id` = #{id} </if> | |||
| <if test=" null != mallName "> and `mall_name` = #{mallName} </if> | |||
| <if test=" null != applicant "> and `applicant` = #{applicant} </if> | |||
| <if test=" null != phone "> and `phone` = #{phone} </if> | |||
| <if test=" null != applyDate "> and `apply_date` = #{applyDate} </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| #{idItem} | |||
| </foreach> | |||
| </if> | |||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||
| </sql> | |||
| <select id="findList" parameterType="com.simple.domain.po.WxMallApply" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns" /> from wx_mall_apply | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| </mapper> | |||
| @@ -7,19 +7,17 @@ | |||
| <result column="img_url" jdbcType="VARCHAR" property="imgUrl" /> | |||
| <result column="name" jdbcType="VARCHAR" property="name" /> | |||
| <result column="link_phone" jdbcType="VARCHAR" property="linkPhone" /> | |||
| <result column="bank_card" jdbcType="VARCHAR" property="bankCard" /> | |||
| <result column="bank_name" jdbcType="VARCHAR" property="bankName" /> | |||
| <result column="receiver_account" jdbcType="BIGINT" property="receiverAccount" /> | |||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | |||
| <result column="car_vendor_type" jdbcType="INTEGER" property="carVendorType" /> | |||
| <result column="car_params" jdbcType="VARCHAR" property="carParams" /> | |||
| <result column="status" jdbcType="INTEGER" property="status" /> | |||
| <result column="link_person" jdbcType="VARCHAR" property="linkPerson" /> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`img_url`,`name`,`link_phone`,`bank_card`,`bank_name`,`receiver_account`,`create_date`,`update_date`,`car_vendor_type`,`car_params`,`status` | |||
| `id`,`tenant_id`,`img_url`,`name`,`link_phone`,`create_date`,`update_date`,`car_vendor_type`,`car_params`,`status`,`link_person` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -48,22 +46,7 @@ | |||
| <if test=" null != linkPhone "> | |||
| and `link_phone` like concat('%', #{linkPhone},'%') | |||
| </if> | |||
| <if test=" null != bankCard "> | |||
| and `bank_card` like concat('%', #{bankCard},'%') | |||
| </if> | |||
| <if test=" null != bankName "> | |||
| and `bank_name` like concat('%', #{bankName},'%') | |||
| </if> | |||
| <if test=" null != receiverAccount "> | |||
| and `receiver_account` = #{receiverAccount} | |||
| </if> | |||
| </if> | |||
| <if test=" null != createDate "> | |||
| and `create_date` = #{createDate} | |||
| @@ -87,8 +70,12 @@ | |||
| <if test=" null != status "> | |||
| and `status` = #{status} | |||
| and `status` = #{status} | |||
| </if> | |||
| <if test=" null != linkPerson "> | |||
| and `link_person` = #{linkPerson} | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| @@ -10,10 +10,12 @@ | |||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | |||
| <result column="rental_start_date" jdbcType="TIMESTAMP" property="rentalStartDate" /> | |||
| <result column="rental_end_date" jdbcType="TIMESTAMP" property="rentalEndDate" /> | |||
| <result column="is_del" jdbcType="SMALLINT" property="isDel" /> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`merchant_id`,`shop_id`,`create_date`,`update_date`,`rental_start_date`,`rental_end_date` | |||
| `id`,`tenant_id`,`merchant_id`,`shop_id`,`create_date`,`update_date`,`rental_start_date`,`rental_end_date`,`is_del` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -55,9 +57,11 @@ | |||
| </if> | |||
| <if test=" null != rentalEndDate "> | |||
| and `rental_end_date` = #{rentalEndDate} | |||
| </if> | |||
| and `rental_end_date` = #{rentalEndDate} | |||
| </if> | |||
| <if test=" null != isDel "> | |||
| and `is_del` = #{isDel} | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| @@ -27,7 +27,7 @@ | |||
| </if> | |||
| <if test=" null != tenantId "> | |||
| and `tenant_id` like concat('%', #{tenantId},'%') | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| @@ -35,7 +35,7 @@ | |||
| </if> | |||
| <if test=" null != tenantId "> | |||
| and `tenant_id` like concat('%', #{tenantId},'%') | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| @@ -36,7 +36,7 @@ | |||
| </if> | |||
| <if test=" null != tenantId "> | |||
| and `tenant_id` like concat('%', #{tenantId},'%') | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||