| @@ -1,5 +1,6 @@ | |||
| package com.simple.controller; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.apache.log4j.Logger; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.GetMapping; | |||
| @@ -9,11 +10,14 @@ import org.springframework.web.bind.annotation.RequestBody; | |||
| import org.springframework.web.bind.annotation.RequestMapping; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.simple.common.Result; | |||
| import com.simple.common.ResultData; | |||
| import com.simple.domain.po.WxCUserBasicInfo; | |||
| import com.simple.domain.po.WxCUserTags; | |||
| import com.simple.service.WxCUserBasicInfoService; | |||
| import com.simple.service.WxCUserTagsService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| @@ -27,6 +31,9 @@ public class WxCUserBasicInfoController extends BaseController | |||
| { | |||
| @Autowired | |||
| private WxCUserBasicInfoService wxCUserBasicInfoService; | |||
| @Autowired | |||
| private WxCUserTagsService wxCUserTagsService; | |||
| private Logger logger = Logger.getLogger(WxCUserBasicInfoController.class); | |||
| @@ -42,20 +49,27 @@ public class WxCUserBasicInfoController extends BaseController | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| public ResultData add(@RequestBody WxCUserBasicInfo wxCUserBasicInfo) { | |||
| //Assert.notNull(wxCUserBasicInfo.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| wxCUserBasicInfo.setTenantId(getTenantId()); | |||
| wxCUserBasicInfoService.saveOrUpdate(wxCUserBasicInfo); | |||
| return new ResultData(); | |||
| } | |||
| // @ApiOperation("新增接口") | |||
| // @PostMapping("add") | |||
| // public ResultData add(@RequestBody WxCUserBasicInfo wxCUserBasicInfo) { | |||
| // //Assert.notNull(wxCUserBasicInfo.getName(), "角色名不能为空"); | |||
| // //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| // wxCUserBasicInfoService.saveOrUpdate(wxCUserBasicInfo); | |||
| // return new ResultData(); | |||
| // } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| public ResultData update(@RequestBody WxCUserBasicInfo wxCUserBasicInfo) { | |||
| wxCUserBasicInfo.setTenantId(getTenantId()); | |||
| if(StringUtils.isNotBlank(wxCUserBasicInfo.getTags())) { | |||
| WxCUserTags record =new WxCUserTags(); | |||
| record.setUserId(wxCUserBasicInfo.getcUserId()); | |||
| record.setTenantId(getTenantId()); | |||
| record.setTags(JSON.toJSONString(wxCUserBasicInfo.getTags())); | |||
| wxCUserTagsService.saveOrUpdate(record); | |||
| wxCUserBasicInfo.setTagId(record.getId()); | |||
| } | |||
| wxCUserBasicInfoService.saveOrUpdate(wxCUserBasicInfo); | |||
| return new ResultData(); | |||
| } | |||
| @@ -59,6 +59,15 @@ public class WxCouponController extends BaseController | |||
| public ResultData add(@RequestBody WxCoupon wxCoupon) { | |||
| //Assert.notNull(wxCoupon.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| if(StringUtils.isNotEmpty(wxCoupon.getSalePriceStr())){ | |||
| wxCoupon.setSalePrice((int)Double.parseDouble(wxCoupon.getSalePriceStr())*100); | |||
| } | |||
| if(StringUtils.isNotEmpty(wxCoupon.getUsePriceStr())){ | |||
| wxCoupon.setUsePrice((int)Double.parseDouble(wxCoupon.getUsePriceStr())*100); | |||
| } | |||
| if(StringUtils.isNotEmpty(wxCoupon.getPriceStr())){ | |||
| wxCoupon.setPrice((int)Double.parseDouble(wxCoupon.getPriceStr())*100); | |||
| } | |||
| if(StringUtils.isNotBlank(wxCoupon.getBusiness())) { | |||
| String[] arys = wxCoupon.getBusiness().split(","); | |||
| wxCoupon.setBusiness(JSON.toJSONString(arys)); | |||
| @@ -1,19 +1,16 @@ | |||
| package com.simple.controller; | |||
| 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; | |||
| import com.simple.common.Result; | |||
| import com.simple.common.ResultData; | |||
| import com.simple.domain.po.WxMerchantBUser; | |||
| import com.simple.service.WxMerchantBUserService; | |||
| 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.*; | |||
| @RestController | |||
| @RequestMapping("wxMerchantBUser") | |||
| @@ -40,6 +37,7 @@ public class WxMerchantBUserController extends BaseController | |||
| public ResultData add(@RequestBody WxMerchantBUser wxMerchantBUser) { | |||
| //Assert.notNull(wxMerchantBUser.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| wxMerchantBUser.setTenantId(getTenantId()); | |||
| wxMerchantBUserService.saveOrUpdate(wxMerchantBUser); | |||
| return new ResultData(); | |||
| } | |||
| @@ -1,19 +1,16 @@ | |||
| package com.simple.controller; | |||
| 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; | |||
| import com.simple.common.Result; | |||
| import com.simple.common.ResultData; | |||
| import com.simple.domain.po.WxMerchant; | |||
| import com.simple.service.WxMerchantService; | |||
| 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.*; | |||
| @RestController | |||
| @RequestMapping("wxMerchant") | |||
| @@ -37,10 +34,11 @@ public class WxMerchantController extends BaseController | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| public ResultData add(@RequestBody WxMerchant wxMerchant) { | |||
| public ResultData add(@ModelAttribute WxMerchant wxMerchant,String shopids, String userids) { | |||
| //Assert.notNull(wxMerchant.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| wxMerchantService.saveOrUpdate(wxMerchant); | |||
| wxMerchant.setTenantId(getTenantId()); | |||
| wxMerchantService.saveOrUpdate(wxMerchant,shopids,userids); | |||
| return new ResultData(); | |||
| } | |||
| @@ -9,45 +9,45 @@ import com.github.pagehelper.PageInfo; | |||
| import com.simple.common.Result; | |||
| import com.simple.common.ResultData; | |||
| import com.simple.domain.po.WxCarCmdLogs; | |||
| import com.simple.service.WxCarCmdLogsService; | |||
| import com.simple.domain.po.WxPayAccount; | |||
| import com.simple.service.WxPayAccountService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| @RestController | |||
| @RequestMapping("wxCarCmdLogs") | |||
| public class WxCarCmdLogsController extends BaseController | |||
| @RequestMapping("wxPayAccount") | |||
| public class WxPayAccountController extends BaseController | |||
| { | |||
| @Autowired | |||
| private WxCarCmdLogsService wxCarCmdLogsService; | |||
| private WxPayAccountService wxPayAccountService; | |||
| private Logger logger = Logger.getLogger(WxCarCmdLogsController.class); | |||
| private Logger logger = Logger.getLogger(WxPayAccountController.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 WxCarCmdLogs wxCarCmdLogs,Integer pageNum, Integer pageSize) { | |||
| if (null == wxCarCmdLogs) wxCarCmdLogs = new WxCarCmdLogs(); | |||
| final PageInfo<WxCarCmdLogs> page = wxCarCmdLogsService.listAsPage(wxCarCmdLogs, pageNum, pageSize); | |||
| public ResultData list(@ModelAttribute WxPayAccount wxPayAccount,Integer pageNum, Integer pageSize) { | |||
| if (null == wxPayAccount) wxPayAccount = new WxPayAccount(); | |||
| final PageInfo<WxPayAccount> page = wxPayAccountService.listAsPage(wxPayAccount, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| public ResultData add(@RequestBody WxCarCmdLogs wxCarCmdLogs) { | |||
| //Assert.notNull(wxCarCmdLogs.getName(), "角色名不能为空"); | |||
| public ResultData add(@RequestBody WxPayAccount wxPayAccount) { | |||
| //Assert.notNull(wxPayAccount.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| wxCarCmdLogsService.saveOrUpdate(wxCarCmdLogs); | |||
| wxPayAccountService.saveOrUpdate(wxPayAccount); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| public ResultData update(@RequestBody WxCarCmdLogs wxCarCmdLogs) { | |||
| wxCarCmdLogsService.saveOrUpdate(wxCarCmdLogs); | |||
| public ResultData update(@RequestBody WxPayAccount wxPayAccount) { | |||
| wxPayAccountService.saveOrUpdate(wxPayAccount); | |||
| return new ResultData(); | |||
| } | |||
| @@ -55,7 +55,7 @@ public class WxCarCmdLogsController extends BaseController | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) | |||
| public ResultData delete(Long id) { | |||
| wxCarCmdLogsService.deleteById(id); | |||
| wxPayAccountService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @@ -63,7 +63,7 @@ public class WxCarCmdLogsController extends BaseController | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) | |||
| public ResultData findById(Long id) { | |||
| return new ResultData(Result.SUCCESS,"查询成功",wxCarCmdLogsService.getById(id)); | |||
| return new ResultData(Result.SUCCESS,"查询成功",wxPayAccountService.getById(id)); | |||
| } | |||
| @@ -0,0 +1,107 @@ | |||
| package com.simple.controller; | |||
| import com.simple.enums.EnumPayWay; | |||
| import com.simple.exception.BizMessageException; | |||
| import com.simple.exception.MallinkException; | |||
| import com.simple.pay.WxPayment; | |||
| import com.simple.service.WxPayOrderService; | |||
| import com.simple.service.WxRefundOrderService; | |||
| import com.simple.utils.XmlUtil; | |||
| import org.apache.commons.io.IOUtils; | |||
| import org.apache.log4j.Logger; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import java.nio.charset.Charset; | |||
| import java.util.LinkedHashMap; | |||
| import java.util.Map; | |||
| @RestController | |||
| @RequestMapping("/WxPay/notify") | |||
| public class WxPayController extends BaseController { | |||
| private Logger logger = Logger.getLogger(WxPayController.class); | |||
| @Autowired | |||
| private WxPayOrderService wxPayOrderService; | |||
| @Autowired | |||
| private WxRefundOrderService wxRefundOrderService; | |||
| /** | |||
| * | |||
| * @return 接收微信异步通知 | |||
| * @throws Exception 可能产生的任何异常 | |||
| */ | |||
| @RequestMapping(value = "/pay", method = RequestMethod.POST) | |||
| public String _payNotify(HttpServletRequest request) throws Exception { | |||
| Map<String, String> paramMap = null; | |||
| String response; | |||
| try { | |||
| String xml = IOUtils.toString(request.getInputStream(), Charset.forName("UTF-8")); | |||
| paramMap = WxPayment.xmlToMap(xml); | |||
| logger.info("payment wxpay, notify, param: " + paramMap.toString() ); | |||
| response = wxPayOrderService.notify(paramMap, EnumPayWay.PAY_WAY_WEAPP); | |||
| logger.info("payment wxpay, notify success, req : " + paramMap.toString() + ", resp: " + response.toString()); | |||
| return response; | |||
| } catch (BizMessageException e) { | |||
| logger.error("payment wxpay, notify error, req: " + paramMap.toString() + ", e:" + e.getLocalizedMessage()); | |||
| Map<String, String> resultMap = new LinkedHashMap<>(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", e.getMessage()); | |||
| return XmlUtil.parseDto2Xml(resultMap, ""); | |||
| } catch (MallinkException e) { | |||
| logger.error("payment wxpay, notify error, req: " + paramMap.toString() + ", e:" +e.getLocalizedMessage()); | |||
| Map<String, String> resultMap = new LinkedHashMap<>(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", e.getMessage()); | |||
| return XmlUtil.parseDto2Xml(resultMap, ""); | |||
| } catch (Exception e) { | |||
| logger.error("payment wxpay, order create error, req: " + paramMap.toString() + ", e: " + e.getMessage()); | |||
| Map<String, String> resultMap = new LinkedHashMap<>(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", e.getMessage()); | |||
| return XmlUtil.parseDto2Xml(resultMap, ""); | |||
| } | |||
| } | |||
| /** | |||
| * | |||
| * @return 接收微信退款异步通知 | |||
| * @throws Exception 可能产生的任何异常 | |||
| */ | |||
| @RequestMapping(value = "/refund", method = RequestMethod.POST) | |||
| public String __refundNotify(HttpServletRequest request) throws Exception { | |||
| Map<String, String> paramMap = null; | |||
| String response; | |||
| try { | |||
| String xml = IOUtils.toString(request.getInputStream(), Charset.forName("UTF-8")); | |||
| paramMap = WxPayment.xmlToMap(xml); | |||
| logger.info("refund wxpay, notify, param: " + paramMap.toString() ); | |||
| response = wxRefundOrderService.notify(paramMap, EnumPayWay.PAY_WAY_WEAPP); | |||
| logger.info("refund wxpay, notify success, req : " + paramMap.toString() + ", resp: " + response.toString()); | |||
| return response; | |||
| } catch (BizMessageException e) { | |||
| logger.error("refund wxpay, notify error, req: " + paramMap.toString() + ", e:" + e.getLocalizedMessage()); | |||
| Map<String, String> resultMap = new LinkedHashMap<>(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", e.getMessage()); | |||
| return XmlUtil.parseDto2Xml(resultMap, ""); | |||
| } catch (MallinkException e) { | |||
| logger.error("refund wxpay, notify error, req: " + paramMap.toString() + ", e:" +e.getLocalizedMessage()); | |||
| Map<String, String> resultMap = new LinkedHashMap<>(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", e.getMessage()); | |||
| return XmlUtil.parseDto2Xml(resultMap, ""); | |||
| } catch (Exception e) { | |||
| logger.error("refund wxpay, order create error, req: " + paramMap.toString() + ", e: " + e.getMessage()); | |||
| Map<String, String> resultMap = new LinkedHashMap<>(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", e.getMessage()); | |||
| return XmlUtil.parseDto2Xml(resultMap, ""); | |||
| } | |||
| } | |||
| } | |||
| @@ -9,45 +9,45 @@ import com.github.pagehelper.PageInfo; | |||
| import com.simple.common.Result; | |||
| import com.simple.common.ResultData; | |||
| import com.simple.domain.po.WxAppinfo; | |||
| import com.simple.service.WxAppinfoService; | |||
| import com.simple.domain.po.WxRefundOrder; | |||
| import com.simple.service.WxRefundOrderService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| @RestController | |||
| @RequestMapping("wxAppinfo") | |||
| public class WxAppinfoController extends BaseController | |||
| @RequestMapping("wxRefundOrder") | |||
| public class WxRefundOrderController extends BaseController | |||
| { | |||
| @Autowired | |||
| private WxAppinfoService wxAppinfoService; | |||
| private WxRefundOrderService wxRefundOrderService; | |||
| private Logger logger = Logger.getLogger(WxAppinfoController.class); | |||
| private Logger logger = Logger.getLogger(WxRefundOrderController.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 WxAppinfo wxAppinfo,Integer pageNum, Integer pageSize) { | |||
| if (null == wxAppinfo) wxAppinfo = new WxAppinfo(); | |||
| final PageInfo<WxAppinfo> page = wxAppinfoService.listAsPage(wxAppinfo, pageNum, pageSize); | |||
| public ResultData list(@ModelAttribute WxRefundOrder wxRefundOrder,Integer pageNum, Integer pageSize) { | |||
| if (null == wxRefundOrder) wxRefundOrder = new WxRefundOrder(); | |||
| final PageInfo<WxRefundOrder> page = wxRefundOrderService.listAsPage(wxRefundOrder, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| public ResultData add(@RequestBody WxAppinfo wxAppinfo) { | |||
| //Assert.notNull(wxAppinfo.getName(), "角色名不能为空"); | |||
| public ResultData add(@RequestBody WxRefundOrder wxRefundOrder) { | |||
| //Assert.notNull(wxRefundOrder.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| wxAppinfoService.saveOrUpdate(wxAppinfo); | |||
| wxRefundOrderService.saveOrUpdate(wxRefundOrder); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| public ResultData update(@RequestBody WxAppinfo wxAppinfo) { | |||
| wxAppinfoService.saveOrUpdate(wxAppinfo); | |||
| public ResultData update(@RequestBody WxRefundOrder wxRefundOrder) { | |||
| wxRefundOrderService.saveOrUpdate(wxRefundOrder); | |||
| return new ResultData(); | |||
| } | |||
| @@ -55,7 +55,7 @@ public class WxAppinfoController extends BaseController | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) | |||
| public ResultData delete(Long id) { | |||
| wxAppinfoService.deleteById(id); | |||
| wxRefundOrderService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @@ -63,7 +63,7 @@ public class WxAppinfoController extends BaseController | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) | |||
| public ResultData findById(Long id) { | |||
| return new ResultData(Result.SUCCESS,"查询成功",wxAppinfoService.getById(id)); | |||
| return new ResultData(Result.SUCCESS,"查询成功",wxRefundOrderService.getById(id)); | |||
| } | |||
| @@ -1,14 +1,20 @@ | |||
| package com.simple.config; | |||
| import com.alibaba.fastjson.serializer.SerializeConfig; | |||
| import com.alibaba.fastjson.serializer.ToStringSerializer; | |||
| import com.alibaba.fastjson.support.config.FastJsonConfig; | |||
| import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; | |||
| import com.simple.interceptor.AuthorizationInterceptor; | |||
| import com.simple.resolver.LoginUserHandlerMethodArgumentResolver; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.context.annotation.Configuration; | |||
| import org.springframework.http.converter.HttpMessageConverter; | |||
| import org.springframework.web.method.support.HandlerMethodArgumentResolver; | |||
| import org.springframework.web.servlet.config.annotation.InterceptorRegistry; | |||
| import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; | |||
| import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; | |||
| import java.math.BigInteger; | |||
| import java.util.List; | |||
| /** | |||
| @@ -44,4 +50,19 @@ public class WebMvcConfig extends WebMvcConfigurerAdapter { | |||
| //registry.addResourceHandler("/app/**").addResourceLocations("classpath:/app/"); | |||
| } | |||
| @Override | |||
| public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { | |||
| FastJsonHttpMessageConverter fastConverter = | |||
| new FastJsonHttpMessageConverter(); | |||
| FastJsonConfig fastJsonConfig = new FastJsonConfig(); | |||
| SerializeConfig serializeConfig = SerializeConfig.globalInstance; | |||
| serializeConfig.put(BigInteger.class, ToStringSerializer.instance); | |||
| serializeConfig.put(Long.class, ToStringSerializer.instance); | |||
| serializeConfig.put(Long.TYPE, ToStringSerializer.instance); | |||
| fastJsonConfig.setSerializeConfig(serializeConfig); | |||
| fastConverter.setFastJsonConfig(fastJsonConfig); | |||
| converters.add(fastConverter); | |||
| } | |||
| } | |||
| @@ -86,4 +86,17 @@ public class BaseController { | |||
| service.setWxMaConfig(config); | |||
| 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); | |||
| return service; | |||
| } | |||
| } | |||
| @@ -1,71 +0,0 @@ | |||
| package com.simple.controller; | |||
| 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; | |||
| import com.simple.common.Result; | |||
| import com.simple.common.ResultData; | |||
| import com.simple.domain.po.WxBLog; | |||
| import com.simple.service.WxBLogService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| @RestController | |||
| @RequestMapping("wxBLog") | |||
| public class WxBLogController extends BaseController | |||
| { | |||
| @Autowired | |||
| private WxBLogService wxBLogService; | |||
| private Logger logger = Logger.getLogger(WxBLogController.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 WxBLog wxBLog,Integer pageNum, Integer pageSize) { | |||
| if (null == wxBLog) wxBLog = new WxBLog(); | |||
| final PageInfo<WxBLog> page = wxBLogService.listAsPage(wxBLog, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| public ResultData add(@RequestBody WxBLog wxBLog) { | |||
| //Assert.notNull(wxBLog.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| wxBLogService.saveOrUpdate(wxBLog); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| public ResultData update(@RequestBody WxBLog wxBLog) { | |||
| wxBLogService.saveOrUpdate(wxBLog); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id删除接口") | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) | |||
| public ResultData delete(Long id) { | |||
| wxBLogService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) | |||
| public ResultData findById(Long id) { | |||
| return new ResultData(Result.SUCCESS,"查询成功",wxBLogService.getById(id)); | |||
| } | |||
| } | |||
| @@ -1,71 +0,0 @@ | |||
| package com.simple.controller; | |||
| 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; | |||
| import com.simple.common.Result; | |||
| import com.simple.common.ResultData; | |||
| import com.simple.domain.po.WxBusiness; | |||
| import com.simple.service.WxBusinessService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| @RestController | |||
| @RequestMapping("wxBusiness") | |||
| public class WxBusinessController extends BaseController | |||
| { | |||
| @Autowired | |||
| private WxBusinessService wxBusinessService; | |||
| private Logger logger = Logger.getLogger(WxBusinessController.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 WxBusiness wxBusiness,Integer pageNum, Integer pageSize) { | |||
| if (null == wxBusiness) wxBusiness = new WxBusiness(); | |||
| final PageInfo<WxBusiness> page = wxBusinessService.listAsPage(wxBusiness, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| public ResultData add(@RequestBody WxBusiness wxBusiness) { | |||
| //Assert.notNull(wxBusiness.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| wxBusinessService.saveOrUpdate(wxBusiness); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| public ResultData update(@RequestBody WxBusiness wxBusiness) { | |||
| wxBusinessService.saveOrUpdate(wxBusiness); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id删除接口") | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) | |||
| public ResultData delete(Long id) { | |||
| wxBusinessService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) | |||
| public ResultData findById(Long id) { | |||
| return new ResultData(Result.SUCCESS,"查询成功",wxBusinessService.getById(id)); | |||
| } | |||
| } | |||
| @@ -1,71 +0,0 @@ | |||
| package com.simple.controller; | |||
| 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; | |||
| import com.simple.common.Result; | |||
| import com.simple.common.ResultData; | |||
| import com.simple.domain.po.WxCUserCars; | |||
| import com.simple.service.WxCUserCarsService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| @RestController | |||
| @RequestMapping("wxCUserCars") | |||
| public class WxCUserCarsController extends BaseController | |||
| { | |||
| @Autowired | |||
| private WxCUserCarsService wxCUserCarsService; | |||
| private Logger logger = Logger.getLogger(WxCUserCarsController.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 WxCUserCars wxCUserCars,Integer pageNum, Integer pageSize) { | |||
| if (null == wxCUserCars) wxCUserCars = new WxCUserCars(); | |||
| final PageInfo<WxCUserCars> page = wxCUserCarsService.listAsPage(wxCUserCars, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| public ResultData add(@RequestBody WxCUserCars wxCUserCars) { | |||
| //Assert.notNull(wxCUserCars.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| wxCUserCarsService.saveOrUpdate(wxCUserCars); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| public ResultData update(@RequestBody WxCUserCars wxCUserCars) { | |||
| wxCUserCarsService.saveOrUpdate(wxCUserCars); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id删除接口") | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) | |||
| public ResultData delete(Long id) { | |||
| wxCUserCarsService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) | |||
| public ResultData findById(Long id) { | |||
| return new ResultData(Result.SUCCESS,"查询成功",wxCUserCarsService.getById(id)); | |||
| } | |||
| } | |||
| @@ -1,71 +0,0 @@ | |||
| package com.simple.controller; | |||
| 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; | |||
| import com.simple.common.Result; | |||
| import com.simple.common.ResultData; | |||
| import com.simple.domain.po.WxCUser; | |||
| import com.simple.service.WxCUserService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| @RestController | |||
| @RequestMapping("wxCUser") | |||
| public class WxCUserController extends BaseController | |||
| { | |||
| @Autowired | |||
| private WxCUserService wxCUserService; | |||
| private Logger logger = Logger.getLogger(WxCUserController.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 WxCUser wxCUser,Integer pageNum, Integer pageSize) { | |||
| if (null == wxCUser) wxCUser = new WxCUser(); | |||
| final PageInfo<WxCUser> page = wxCUserService.listAsPage(wxCUser, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| public ResultData add(@RequestBody WxCUser wxCUser) { | |||
| //Assert.notNull(wxCUser.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| wxCUserService.saveOrUpdate(wxCUser); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| public ResultData update(@RequestBody WxCUser wxCUser) { | |||
| wxCUserService.saveOrUpdate(wxCUser); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id删除接口") | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) | |||
| public ResultData delete(Long id) { | |||
| wxCUserService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) | |||
| public ResultData findById(Long id) { | |||
| return new ResultData(Result.SUCCESS,"查询成功",wxCUserService.getById(id)); | |||
| } | |||
| } | |||
| @@ -1,71 +0,0 @@ | |||
| package com.simple.controller; | |||
| 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; | |||
| import com.simple.common.Result; | |||
| import com.simple.common.ResultData; | |||
| import com.simple.domain.po.WxCUserTags; | |||
| import com.simple.service.WxCUserTagsService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| @RestController | |||
| @RequestMapping("wxCUserTags") | |||
| public class WxCUserTagsController extends BaseController | |||
| { | |||
| @Autowired | |||
| private WxCUserTagsService wxCUserTagsService; | |||
| private Logger logger = Logger.getLogger(WxCUserTagsController.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 WxCUserTags wxCUserTags,Integer pageNum, Integer pageSize) { | |||
| if (null == wxCUserTags) wxCUserTags = new WxCUserTags(); | |||
| final PageInfo<WxCUserTags> page = wxCUserTagsService.listAsPage(wxCUserTags, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| public ResultData add(@RequestBody WxCUserTags wxCUserTags) { | |||
| //Assert.notNull(wxCUserTags.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| wxCUserTagsService.saveOrUpdate(wxCUserTags); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| public ResultData update(@RequestBody WxCUserTags wxCUserTags) { | |||
| wxCUserTagsService.saveOrUpdate(wxCUserTags); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id删除接口") | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) | |||
| public ResultData delete(Long id) { | |||
| wxCUserTagsService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) | |||
| public ResultData findById(Long id) { | |||
| return new ResultData(Result.SUCCESS,"查询成功",wxCUserTagsService.getById(id)); | |||
| } | |||
| } | |||
| @@ -26,7 +26,7 @@ import java.util.HashMap; | |||
| import java.util.Map; | |||
| @RestController | |||
| @RequestMapping("car") | |||
| @RequestMapping("/api/car") | |||
| public class WxCarController extends BaseController | |||
| { | |||
| private Logger logger = Logger.getLogger(WxCarController.class); | |||
| @@ -52,7 +52,7 @@ public class WxCarController extends BaseController | |||
| } | |||
| @ApiOperation(value = "获取车场支持的厂家",notes="") | |||
| @GetMapping("getVendor") | |||
| @GetMapping("/getVendor") | |||
| public ResultData getVendor() { | |||
| // 1, get mall's park | |||
| WxPark park = getCurrentPark(); | |||
| @@ -67,7 +67,7 @@ public class WxCarController extends BaseController | |||
| * @return | |||
| */ | |||
| @ApiOperation(value = "初始化/etcp共同登录",notes="{\"phone\":\"string\"}") | |||
| @PostMapping("init") | |||
| @PostMapping("/init") | |||
| public ResultData init(Map<String, String > paramMap) { | |||
| // 1, get mall's park | |||
| WxPark park = getCurrentPark(); | |||
| @@ -133,7 +133,7 @@ public class WxCarController extends BaseController | |||
| */ | |||
| @ApiOperation(value = "绑车牌", notes = "ETCP:={\"etcpToken\":\"string\",\"carNumber\":\"string\"}\n" + | |||
| "TJD:={\"carNumber\":\"string\",\"carNumColor\":\"string\",\"outCarId\":\"string\"}") | |||
| @PostMapping("bindCar") | |||
| @PostMapping("/bindCar") | |||
| public ResultData bindCar(Map<String, String > paramMap) { | |||
| // 1, get mall's park | |||
| WxPark park = getCurrentPark(); | |||
| @@ -217,7 +217,7 @@ public class WxCarController extends BaseController | |||
| */ | |||
| @ApiOperation(value = "解绑车牌", notes = "ETCP:={\"etcpToken\":\"string\",\"carNumber\":\"string\"}\n" + | |||
| "TJD:={\"carNumber\":\"string\",\"carNumColor\":\"string\",\"outCarId\":\"string\"}") | |||
| @PostMapping("unbindCar") | |||
| @PostMapping("/unbindCar") | |||
| public ResultData unbindCar(Map<String, String > paramMap) { | |||
| // 1, get mall's park | |||
| WxPark park = getCurrentPark(); | |||
| @@ -292,7 +292,7 @@ public class WxCarController extends BaseController | |||
| */ | |||
| @ApiOperation(value = "停车费", notes = "ETCP:={\"etcpToken\":\"string\",\"carNumber\":\"string\"}\n" + | |||
| "TJD:={\"carNumber\":\"string\",\"carNumColor\":\"string\",\"outCarId\":\"string\"}") | |||
| @PostMapping("getCarStopFee") | |||
| @PostMapping("/getCarStopFee") | |||
| public ResultData getCarStopFee(Map<String, String > paramMap) { | |||
| // 1, get mall's park | |||
| WxPark park = getCurrentPark(); | |||
| @@ -392,7 +392,7 @@ public class WxCarController extends BaseController | |||
| * | |||
| */ | |||
| @ApiOperation("停车费抵扣") | |||
| @PostMapping("deductionFee") | |||
| @PostMapping("/deductionFee") | |||
| public ResultData deductionFee(Map<String, String > paramMap) { | |||
| /// 1, get mall's park | |||
| WxPark park = getCurrentPark(); | |||
| @@ -460,7 +460,7 @@ public class WxCarController extends BaseController | |||
| }, | |||
| */ | |||
| @ApiOperation("优免券模板") | |||
| @PostMapping("quanTemplate") | |||
| @PostMapping("/quanTemplate") | |||
| public ResultData quanTemplate(Map<String, String > paramMap) { | |||
| /// 1, get mall's park | |||
| WxPark park = getCurrentPark(); | |||
| @@ -511,7 +511,7 @@ public class WxCarController extends BaseController | |||
| * 优免券不可退 | |||
| */ | |||
| @ApiOperation(value = "优免券领取", notes="ETCP:={\"etcpToken\":\"string\",\"carNumber\":\"string\",\"couponFreeId\":\"string\"}") | |||
| @PostMapping("getCoupon") | |||
| @PostMapping("/getCoupon") | |||
| public ResultData getCoupon(Map<String, String > paramMap) { | |||
| /// 1, get mall's park | |||
| WxPark park = getCurrentPark(); | |||
| @@ -23,9 +23,9 @@ public class WxCouponController extends BaseController | |||
| @Autowired | |||
| private WxCouponService wxCouponService; | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("list") | |||
| @GetMapping("/list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true), | |||
| @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)}) | |||
| @@ -58,14 +58,14 @@ public class WxCouponController extends BaseController | |||
| wxCouponService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) | |||
| public ResultData findById(Long id) { | |||
| return new ResultData(Result.SUCCESS,"查询成功",wxCouponService.getById(id)); | |||
| } | |||
| } | |||
| @@ -23,14 +23,14 @@ import io.swagger.annotations.ApiOperation; | |||
| import java.util.Map; | |||
| @RestController | |||
| @RequestMapping("wxOrder") | |||
| @RequestMapping("/api/order/") | |||
| public class WxOrderController extends BaseController { | |||
| private Logger logger = Logger.getLogger(WxOrderController.class); | |||
| @Autowired | |||
| private WxOrderService wxOrderService; | |||
| @ApiOperation(value = "提交订单", notes = "{\"couponId\":\"String\"}") | |||
| @ApiOperation(value = "下订单", notes = "{\"couponId\":\"String\"}") | |||
| @PostMapping("save") | |||
| public ResultData saveOrder(@RequestBody Map<String, String> paramMap) { | |||
| //Assert.notNull(wxOrders.getName(), "角色名不能为空"); | |||
| @@ -47,8 +47,8 @@ public class WxOrderController extends BaseController { | |||
| return new ResultData(order); | |||
| }catch (MallinkException e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("取消订单") | |||
| @@ -90,28 +90,18 @@ public class WxOrderController extends BaseController { | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| public ResultData add(@RequestBody WxOrder wxOrder) { | |||
| //Assert.notNull(wxOrder.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| wxOrderService.saveOrUpdate(wxOrder); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| public ResultData update(@RequestBody WxOrder wxOrder) { | |||
| wxOrderService.saveOrUpdate(wxOrder); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id删除接口") | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| public ResultData delete(Long id) { | |||
| wxOrderService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| @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 WxOrder wxOrder, Integer pageNum, Integer pageSize) { | |||
| if (null == wxOrder) wxOrder = new WxOrder(); | |||
| // c端用户应该只能看到自己的订单 | |||
| WxCUser user = getUser(); | |||
| wxOrder.setCUserId(user.getId()); | |||
| final PageInfo<WxOrder> page = wxOrderService.listAsPage(wxOrder, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @@ -1,6 +1,7 @@ | |||
| package com.simple.controller; | |||
| import cn.binarywang.wx.miniapp.api.WxMaService; | |||
| import com.simple.annotation.AuthIgnore; | |||
| import com.simple.common.ErrorCode; | |||
| import com.simple.domain.po.WxAppinfo; | |||
| import com.simple.domain.po.WxCUser; | |||
| @@ -10,6 +11,7 @@ import com.simple.exception.BizMessageException; | |||
| import com.simple.exception.MallinkException; | |||
| import com.simple.pay.WxPayment; | |||
| import com.simple.utils.IPUtil; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.apache.log4j.Logger; | |||
| import org.apache.commons.io.IOUtils; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| @@ -31,7 +33,7 @@ import java.nio.charset.Charset; | |||
| import java.util.Map; | |||
| @RestController | |||
| @RequestMapping("wxPayOrder") | |||
| @RequestMapping("/api/pay") | |||
| public class WxPayOrderController extends BaseController { | |||
| private Logger logger = Logger.getLogger(WxPayOrderController.class); | |||
| @@ -40,15 +42,22 @@ public class WxPayOrderController extends BaseController { | |||
| private WxPayOrderService wxPayOrderService; | |||
| @ApiOperation(value = "发起微信小程序支付订单") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "orderId", value = "订单ID", required = true, dataType = "Long"), | |||
| @ApiImplicitParam(name = "payVendor", value = "支付发起渠道:0-微信小程序", defaultValue = "0",required = false, dataType = "Integer") | |||
| }) | |||
| @RequestMapping(value = "/create", method = RequestMethod.POST) | |||
| public ResultData _create(WxPayOrder record, HttpServletRequest request) throws Exception { | |||
| logger.info("payment wechat, order create, param : " + record.toString()); | |||
| public ResultData _create(@RequestBody Map<String, String> paramMap, HttpServletRequest request) throws Exception { | |||
| logger.info("/api/pay/create" + paramMap.toString()); | |||
| String orderIdStr = paramMap.get("orderId"); | |||
| if (StringUtils.isBlank(orderIdStr)) { | |||
| logger.info("orderId不能为空: " + paramMap.toString()); | |||
| return new ResultData(ErrorCode.PARAMETER_NOT_NULL.getCode(), "orderId不能为空"); | |||
| } | |||
| WxCUser user = getUser(); | |||
| WxAppinfo appInfo = getAppInfo(user.getAppId()); | |||
| Long orderId = Long.valueOf(orderIdStr); | |||
| WxPayOrder record = new WxPayOrder(); | |||
| record.setOrderId(orderId); | |||
| try { | |||
| record.setIp(IPUtil.getIpAddr(request)); | |||
| return wxPayOrderService.createPayOrder(appInfo, user, record, EnumPayWay.PAY_WAY_WECHAT); | |||
| @@ -66,7 +75,8 @@ public class WxPayOrderController extends BaseController { | |||
| * @return 接收微信异步通知 | |||
| * @throws Exception 可能产生的任何异常 | |||
| */ | |||
| @RequestMapping(value = "/notify", method = RequestMethod.POST) | |||
| @AuthIgnore | |||
| @RequestMapping(value = "/notify/pay", method = RequestMethod.POST) | |||
| public String __doNotify(HttpServletRequest request) throws Exception { | |||
| Map<String, String> paramMap = null; | |||
| String response; | |||
| @@ -94,7 +104,7 @@ public class WxPayOrderController extends BaseController { | |||
| * @return 同步回调(订单状态主动检查) | |||
| * @throws Exception 可能产生的任何异常 | |||
| */ | |||
| @RequestMapping(value = "callback", method = {RequestMethod.GET, RequestMethod.POST}) | |||
| @RequestMapping(value = "/callback", method = {RequestMethod.GET, RequestMethod.POST}) | |||
| public String __doCallback(HttpServletRequest request) throws Exception { | |||
| logger.info("payment wxpay, callback,request:" + request.toString()); | |||
| @@ -109,7 +119,7 @@ public class WxPayOrderController extends BaseController { | |||
| } | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("list") | |||
| @GetMapping("/list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true), | |||
| @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)}) | |||
| @@ -120,7 +130,7 @@ public class WxPayOrderController extends BaseController { | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| @PostMapping("/add") | |||
| public ResultData add(@RequestBody WxPayOrder wxPayOrder) { | |||
| //Assert.notNull(wxPayOrder.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| @@ -129,7 +139,7 @@ public class WxPayOrderController extends BaseController { | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| @PostMapping("/update") | |||
| public ResultData update(@RequestBody WxPayOrder wxPayOrder) { | |||
| wxPayOrderService.saveOrUpdate(wxPayOrder); | |||
| return new ResultData(); | |||
| @@ -1,71 +0,0 @@ | |||
| package com.simple.controller; | |||
| 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; | |||
| import com.simple.common.Result; | |||
| import com.simple.common.ResultData; | |||
| import com.simple.domain.po.WxTags; | |||
| import com.simple.service.WxTagsService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| @RestController | |||
| @RequestMapping("wxTags") | |||
| public class WxTagsController extends BaseController | |||
| { | |||
| @Autowired | |||
| private WxTagsService wxTagsService; | |||
| private Logger logger = Logger.getLogger(WxTagsController.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 WxTags wxTags,Integer pageNum, Integer pageSize) { | |||
| if (null == wxTags) wxTags = new WxTags(); | |||
| final PageInfo<WxTags> page = wxTagsService.listAsPage(wxTags, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| public ResultData add(@RequestBody WxTags wxTags) { | |||
| //Assert.notNull(wxTags.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| wxTagsService.saveOrUpdate(wxTags); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| public ResultData update(@RequestBody WxTags wxTags) { | |||
| wxTagsService.saveOrUpdate(wxTags); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id删除接口") | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) | |||
| public ResultData delete(Long id) { | |||
| wxTagsService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) | |||
| public ResultData findById(Long id) { | |||
| return new ResultData(Result.SUCCESS,"查询成功",wxTagsService.getById(id)); | |||
| } | |||
| } | |||
| @@ -10,22 +10,21 @@ import com.alibaba.druid.wall.WallConfig; | |||
| import com.simple.annotation.AuthIgnore; | |||
| 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.WxAppinfo; | |||
| import com.simple.domain.po.WxCUser; | |||
| import com.simple.service.WxAppinfoService; | |||
| import com.simple.service.WxCUserService; | |||
| import com.simple.utils.IPUtil; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import me.chanjar.weixin.common.error.WxErrorException; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.PostMapping; | |||
| import org.springframework.web.bind.annotation.RequestBody; | |||
| import org.springframework.web.bind.annotation.RequestMapping; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import org.springframework.web.context.request.RequestContextHolder; | |||
| import org.springframework.web.context.request.ServletRequestAttributes; | |||
| @@ -56,16 +55,20 @@ public class WxUserGrantController extends BaseController { | |||
| Map resultMap = new HashMap(); | |||
| String appId = map.get("appId"); | |||
| WxMaService wxMaService = getWeappService(appId); | |||
| String code = map.get("code"); | |||
| String scene = map.get("scene"); | |||
| String code = map.get("code"); | |||
| String sceneAddress = map.get("sceneAddress"); | |||
| //登录凭证不能为空 | |||
| if (StringUtils.isBlank(appId)) { | |||
| return new ResultData(ErrorCode.PARAMETER_NOT_NULL.getCode(), "appId不能为空"); | |||
| } | |||
| if (StringUtils.isBlank(code)) { | |||
| return new ResultData(ErrorCode.PARAMETER_NOT_NULL.getCode(), "code不能为空"); | |||
| } | |||
| // 通过appinfo得到tenant_id | |||
| WxAppinfo wxAppinfo = getAppInfo(appId); | |||
| WxMaService wxMaService = getWeappServiceByAppInfo(wxAppinfo); | |||
| String token = null; | |||
| String session_key = null; | |||
| String openId = null; | |||
| @@ -95,18 +98,15 @@ public class WxUserGrantController extends BaseController { | |||
| token = user1.getToken(); | |||
| user1.setRegisterIp(ipaddress); | |||
| user1.setSessionKey(session_key); | |||
| if (user1.getScene() == null) | |||
| user1.setScene(scene); | |||
| if (user1.getSceneAddress() == null) | |||
| user1.setSceneAddress(sceneAddress); | |||
| wxCUserService.saveOrUpdate(user1); | |||
| resultMap.put("token", token); | |||
| } else { | |||
| user.setTenantId(wxAppinfo.getTenantId()); | |||
| user.createToken(new Date()); | |||
| token = user.getToken(); | |||
| user.setRegisterIp(ipaddress); | |||
| if (user.getScene() == null) | |||
| user.setScene(scene); | |||
| if (user.getSceneAddress() == null) | |||
| user.setSceneAddress(sceneAddress); | |||
| @@ -227,77 +227,11 @@ public class WxUserGrantController extends BaseController { | |||
| } | |||
| } | |||
| /** | |||
| * 判断是否是老用户 | |||
| * @param map | |||
| * @return | |||
| */ | |||
| /* | |||
| @PostMapping("/isOldUser") | |||
| @ApiOperation(value = "判断是否是老用户", notes="{\"openId\":\"\"}") | |||
| public R isOldUser(@RequestBody Map<String, String> map) { | |||
| logger.debug(map.toString()); | |||
| String openId = map.get("openId"); | |||
| //登录凭证不能为空 | |||
| if (StringUtils.isBlank(openId)) { | |||
| return R.code(1, "openId 不能为空"); | |||
| } | |||
| R r = new R(); | |||
| try { | |||
| WxUserEntity user1 = wxUserService.queryObjectByOpenId(openId); | |||
| if (user1 != null) { | |||
| logger.info(user1.toString()); | |||
| // nickname, unionId is null, 31 | |||
| // phone is null, 29, | |||
| // idcard,name is null, 30 | |||
| // all have, 32 | |||
| if (!StringUtils.isBlank(user1.getUnionid())) { | |||
| r.put("unionId", user1.getUnionid()); | |||
| } | |||
| if (!StringUtils.isBlank(user1.getPhone())) { | |||
| r.put("phone", user1.getPhone()); | |||
| } | |||
| if (!StringUtils.isBlank(user1.getVipno())) { | |||
| r.put("memberId", user1.getVipno()); | |||
| } | |||
| if (StringUtils.isBlank(user1.getUnionid())) { | |||
| r.put("type", 31).put("code", 31); | |||
| r.put("msg", "是新用户,请跳转到用户授权页!"); | |||
| logger.warn("是新用户,跳转到用户授权页!"); | |||
| return r; | |||
| } | |||
| if (StringUtils.isBlank(user1.getPhone())) { | |||
| r.put("type", 29).put("code", 29); | |||
| r.put("msg", "是新用户,跳转到授权手机号页!"); | |||
| logger.warn("是新用户,跳转到授权手机号页!"); | |||
| return r; | |||
| } | |||
| if (StringUtils.isBlank(user1.getVipno())) { | |||
| r.put("type",28).put("code", 28); | |||
| r.put("msg", "是新用户,跳转到注册华联会员!"); | |||
| logger.warn("是新用户,跳转到注册华联会员!"); | |||
| return r; | |||
| } | |||
| r.put("type",32).put("code", 32); | |||
| r.put("msg", "老用户"); | |||
| return r; | |||
| } else { | |||
| r.put("type", 31).put("code", 31); | |||
| r.put("msg", "是新用户,请跳转到用户授权页!"); | |||
| logger.warn("是新用户,跳转到用户授权页!"); | |||
| return r; | |||
| } | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage(), e); | |||
| return R.error(e.toString()); | |||
| } | |||
| }*/ | |||
| @ApiOperation("获取用户信息") | |||
| @GetMapping("/findById") | |||
| public ResultData getUserInfo() { | |||
| WxCUser user = getUser(); | |||
| return new ResultData(Result.SUCCESS,"查询成功",user); | |||
| } | |||
| } | |||
| @@ -1,9 +1,9 @@ | |||
| spring: | |||
| # JDBC | |||
| datasource: | |||
| url: jdbc:mysql://202.165.179.86:3306/mallink?characterEncoding=UTF-8&useSSL=false | |||
| username: mallone | |||
| password: m@1l0ne123@# | |||
| url: jdbc:mysql://localhost:3306/mallink?characterEncoding=UTF-8&useSSL=false | |||
| username: userone | |||
| password: 123456 | |||
| type: com.alibaba.druid.pool.DruidDataSource | |||
| driver-class-name: com.mysql.jdbc.Driver | |||
| filters: stat | |||
| @@ -72,9 +72,17 @@ public enum ErrorCode{ | |||
| * 订单 | |||
| */ | |||
| REMAIN_IS_EMPTY(3000, "库存不足"), | |||
| ORDER_IS_FAIL(3001, "订单创建失败"), | |||
| ORDER_IS_NOT_FIND(3002, "订单不存在"), | |||
| ORDER_IS_NOT_PAY(3003, "订单已不能进行支付"), | |||
| ORDER_IS_LIMITED(3001, "购买超限"), | |||
| ORDER_IS_FAIL(3002, "订单创建失败"), | |||
| ORDER_IS_NOT_FIND(3003, "订单不存在"), | |||
| ORDER_IS_NOT_PAY(3004, "订单已不能进行支付"), | |||
| /** | |||
| * 卡券 | |||
| */ | |||
| COUPON_ORDER_IS_USED(4000, "卡券已核销"), | |||
| COUPON_ORDER_IS_OVER_TIME(4001, "卡券已过期"), | |||
| COUPON_ORDER_IS_INVALID(4002, "卡券已经作废"), | |||
| /** | |||
| * 微信 | |||
| @@ -88,8 +96,19 @@ public enum ErrorCode{ | |||
| * 支付 | |||
| */ | |||
| PAY_ORDER_EXIST(12001, "支付订单已存在"), | |||
| PAY_ORDER_ERROR(12004, "支付订单异常"), | |||
| PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR(12005 , "验签失败"); | |||
| PAY_ORDER_ERROR(12002, "支付订单异常"), | |||
| PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR(12003 , "支付验签失败"), | |||
| REFUND_ORDER_EXIST(12010, "退款订单已存在"), | |||
| REFUND_PAY_ORDER_IS_NOT_EXIST(12011, "退款支付订单不存在"), | |||
| REFUND_PAY_ORDER_IS_ZERO(12012, "退款支付订单金额为0"), | |||
| REFUND_ORDER_ERROR(12013, "退款订单异常"), | |||
| REFUND_ORDER_NOTIFY_CHECK_SIGN_ERROR(12014, "退款验签失败"), | |||
| APP_ID_NOT_FOUND(12020, "APPID没找到"), | |||
| MCH_INFO_NOT_FOUND(12021, "商户信息没找到"), | |||
| MCH_INFO_NOT_EQUAL(12022, "商户信息不对应"), | |||
| ; | |||
| @@ -63,12 +63,6 @@ public class WxAppinfo implements Serializable { | |||
| /*消息类型**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="消息类型",name="msgDataFormat") | |||
| private String msgDataFormat; | |||
| /*微信商户ID**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="微信商户ID",name="mchId") | |||
| private String mchId; | |||
| /*微信支付回调**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="微信支付回调",name="notifyUrl") | |||
| private String notifyUrl; | |||
| /*微信访问token**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="微信访问token",name="accessToken") | |||
| private String accessToken; | |||
| @@ -78,6 +72,9 @@ public class WxAppinfo implements Serializable { | |||
| /*微信token有效时间单位(秒)**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="微信token有效时间单位(秒)",name="expiresIn") | |||
| private Integer expiresIn; | |||
| /*支付ID,参看wx_pay_account**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="支付ID,参看wx_pay_account",name="payId") | |||
| private Long payId; | |||
| public String getTenantId() { | |||
| return tenantId; | |||
| } | |||
| @@ -120,18 +117,6 @@ public class WxAppinfo implements Serializable { | |||
| public void setMsgDataFormat(String _msgDataFormat) { | |||
| msgDataFormat = _msgDataFormat; | |||
| } | |||
| public String getMchId() { | |||
| return mchId; | |||
| } | |||
| public void setMchId(String _mchId) { | |||
| mchId = _mchId; | |||
| } | |||
| public String getNotifyUrl() { | |||
| return notifyUrl; | |||
| } | |||
| public void setNotifyUrl(String _notifyUrl) { | |||
| notifyUrl = _notifyUrl; | |||
| } | |||
| public String getAccessToken() { | |||
| return accessToken; | |||
| } | |||
| @@ -150,6 +135,12 @@ public class WxAppinfo implements Serializable { | |||
| public void setExpiresIn(Integer _expiresIn) { | |||
| expiresIn = _expiresIn; | |||
| } | |||
| public Long getPayId() { | |||
| return payId; | |||
| } | |||
| public void setPayId(Long _payId) { | |||
| payId = _payId; | |||
| } | |||
| @@ -163,11 +154,10 @@ public class WxAppinfo implements Serializable { | |||
| ,Token_ASC("`token` ASC"),Token_DESC("`token` DESC") | |||
| ,AesKey_ASC("`aesKey` ASC"),AesKey_DESC("`aesKey` DESC") | |||
| ,MsgDataFormat_ASC("`msgDataFormat` ASC"),MsgDataFormat_DESC("`msgDataFormat` DESC") | |||
| ,MchId_ASC("`mchId` ASC"),MchId_DESC("`mchId` DESC") | |||
| ,NotifyUrl_ASC("`notifyUrl` ASC"),NotifyUrl_DESC("`notifyUrl` 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") | |||
| ; | |||
| private String value; | |||
| Field(String value){ | |||
| @@ -81,6 +81,28 @@ public class WxCUserBasicInfo implements Serializable { | |||
| /*商户id**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="商户id",name="merchantId") | |||
| private Long merchantId; | |||
| @io.swagger.annotations.ApiModelProperty(value="标签-传json",name="tags") | |||
| @Transient | |||
| private String tags ; | |||
| public Long getcUserId() { | |||
| return cUserId; | |||
| } | |||
| public void setcUserId(Long cUserId) { | |||
| this.cUserId = cUserId; | |||
| } | |||
| public String getTags() { | |||
| return tags; | |||
| } | |||
| public void setTags(String tags) { | |||
| this.tags = tags; | |||
| } | |||
| public String getPhone() { | |||
| return phone; | |||
| } | |||
| @@ -1,40 +1,42 @@ | |||
| package com.simple.domain.po; | |||
| import javax.persistence.Id; | |||
| import javax.persistence.Table; | |||
| import javax.persistence.*; | |||
| import java.util.*; | |||
| import java.math.*; | |||
| import javax.persistence.Transient; | |||
| import java.io.Serializable; | |||
| import java.math.BigDecimal; | |||
| import java.util.List; | |||
| import javax.persistence.Id; | |||
| import java.io.Serializable; | |||
| @Table(name = "wx_mall") | |||
| public class WxMall implements Serializable { | |||
| private static final long serialVersionUID = 1L; | |||
| @Id | |||
| protected Long mallId; | |||
| protected Long id; | |||
| @Transient | |||
| protected List<String> ids; | |||
| protected List<Long> ids; | |||
| @Transient | |||
| protected String sortColumns; | |||
| public Long getMallId() { | |||
| return mallId; | |||
| public Long getId() { | |||
| return id; | |||
| } | |||
| public void setMallId(Long mallId) { | |||
| this.mallId = mallId; | |||
| public void setId(Long id) { | |||
| this.id = id; | |||
| } | |||
| public String getSortColumns() { | |||
| return sortColumns; | |||
| } | |||
| public List<String> getIds() { | |||
| public List<Long> getIds() { | |||
| return ids; | |||
| } | |||
| public void setIds(List<String> ids) { | |||
| public void setIds(List<Long> ids) { | |||
| this.ids = ids; | |||
| } | |||
| @@ -76,6 +78,9 @@ public class WxMall implements Serializable { | |||
| /*车位数**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="车位数",name="parkPlaceNumber") | |||
| private Integer parkPlaceNumber; | |||
| /*支付ID,参看wx_pay_account**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="支付ID,参看wx_pay_account",name="payId") | |||
| private Long payId; | |||
| public String getTenantId() { | |||
| return tenantId; | |||
| } | |||
| @@ -148,12 +153,18 @@ public class WxMall implements Serializable { | |||
| public void setParkPlaceNumber(Integer _parkPlaceNumber) { | |||
| parkPlaceNumber = _parkPlaceNumber; | |||
| } | |||
| public Long getPayId() { | |||
| return payId; | |||
| } | |||
| public void setPayId(Long _payId) { | |||
| payId = _payId; | |||
| } | |||
| public static enum Field | |||
| { | |||
| Id_ASC("`mallId` ASC"),Id_DESC("`mallId` DESC") | |||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||
| ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") | |||
| ,Name_ASC("`name` ASC"),Name_DESC("`name` DESC") | |||
| ,Group_ASC("`group` ASC"),Group_DESC("`group` DESC") | |||
| @@ -166,6 +177,7 @@ public class WxMall implements Serializable { | |||
| ,OperatingArea_ASC("`operatingArea` ASC"),OperatingArea_DESC("`operatingArea` DESC") | |||
| ,ParkArea_ASC("`parkArea` ASC"),ParkArea_DESC("`parkArea` DESC") | |||
| ,ParkPlaceNumber_ASC("`parkPlaceNumber` ASC"),ParkPlaceNumber_DESC("`parkPlaceNumber` DESC") | |||
| ,PayId_ASC("`payId` ASC"),PayId_DESC("`payId` DESC") | |||
| ; | |||
| private String value; | |||
| Field(String value){ | |||
| @@ -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") | |||
| public class WxMerchant implements Serializable { | |||
| @@ -16,7 +15,7 @@ public class WxMerchant implements Serializable { | |||
| protected Long id; | |||
| @Transient | |||
| protected List<String> ids; | |||
| protected List<Long> ids; | |||
| @Transient | |||
| protected String sortColumns; | |||
| @@ -32,10 +31,10 @@ public class WxMerchant implements Serializable { | |||
| return sortColumns; | |||
| } | |||
| public List<String> getIds() { | |||
| public List<Long> getIds() { | |||
| return ids; | |||
| } | |||
| public void setIds(List<String> ids) { | |||
| public void setIds(List<Long> ids) { | |||
| this.ids = ids; | |||
| } | |||
| @@ -59,9 +58,9 @@ public class WxMerchant implements Serializable { | |||
| /*银行开户行**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="银行开户行",name="bankName") | |||
| private String bankName; | |||
| /*微信收款账号**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="微信收款账号",name="wxchatAccount") | |||
| private String wxchatAccount; | |||
| /*支付ID,参看wx_pay_account**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="支付ID,参看wx_pay_account",name="payId") | |||
| private Long payId; | |||
| /*创建时间**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | |||
| private Date createDate; | |||
| @@ -74,6 +73,10 @@ public class WxMerchant implements Serializable { | |||
| /*停车厂商参数**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="停车厂商参数",name="carParams") | |||
| private String carParams; | |||
| @io.swagger.annotations.ApiModelProperty(value="状态1可用0停用",name="status") | |||
| private Integer status; | |||
| public String getTenantId() { | |||
| return tenantId; | |||
| } | |||
| @@ -110,11 +113,11 @@ public class WxMerchant implements Serializable { | |||
| public void setBankName(String _bankName) { | |||
| bankName = _bankName; | |||
| } | |||
| public String getWxchatAccount() { | |||
| return wxchatAccount; | |||
| public Long getPayId() { | |||
| return payId; | |||
| } | |||
| public void setWxchatAccount(String _wxchatAccount) { | |||
| wxchatAccount = _wxchatAccount; | |||
| public void setPayId(Long _payId) { | |||
| payId = _payId; | |||
| } | |||
| public Date getCreateDate() { | |||
| return createDate; | |||
| @@ -141,7 +144,13 @@ public class WxMerchant implements Serializable { | |||
| carParams = _carParams; | |||
| } | |||
| public Integer getStatus() { | |||
| return status; | |||
| } | |||
| public void setStatus(Integer status) { | |||
| this.status = status; | |||
| } | |||
| public static enum Field | |||
| { | |||
| @@ -152,12 +161,14 @@ public class WxMerchant implements Serializable { | |||
| ,LinkPhone_ASC("`linkPhone` ASC"),LinkPhone_DESC("`linkPhone` DESC") | |||
| ,BankCard_ASC("`bankCard` ASC"),BankCard_DESC("`bankCard` DESC") | |||
| ,BankName_ASC("`bankName` ASC"),BankName_DESC("`bankName` DESC") | |||
| ,WxchatAccount_ASC("`wxchatAccount` ASC"),WxchatAccount_DESC("`wxchatAccount` 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") | |||
| ; | |||
| ,Status_ASC("`status` ASC"),Status_DESC("`status` DESC") | |||
| ; | |||
| private String value; | |||
| Field(String value){ | |||
| this.value = value; | |||
| @@ -72,6 +72,9 @@ public class WxOrder implements Serializable { | |||
| /*更新时间**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | |||
| private Date updateDate; | |||
| /*支付描述,订单支付时用**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="支付描述,订单支付时用",name="detail") | |||
| private String detail; | |||
| public Long getOrderNumber() { | |||
| return orderNumber; | |||
| } | |||
| @@ -132,6 +135,12 @@ public class WxOrder implements Serializable { | |||
| public void setUpdateDate(Date _updateDate) { | |||
| updateDate = _updateDate; | |||
| } | |||
| public String getDetail() { | |||
| return detail; | |||
| } | |||
| public void setDetail(String _detail) { | |||
| detail = _detail; | |||
| } | |||
| @@ -148,6 +157,7 @@ public class WxOrder implements Serializable { | |||
| ,OrderStatus_ASC("`orderStatus` ASC"),OrderStatus_DESC("`orderStatus` DESC") | |||
| ,CreateDate_ASC("`createDate` ASC"),CreateDate_DESC("`createDate` DESC") | |||
| ,UpdateDate_ASC("`updateDate` ASC"),UpdateDate_DESC("`updateDate` DESC") | |||
| ,Detail_ASC("`detail` ASC"),Detail_DESC("`detail` DESC") | |||
| ; | |||
| private String value; | |||
| Field(String value){ | |||
| @@ -0,0 +1,150 @@ | |||
| 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_pay_account") | |||
| public class WxPayAccount 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; | |||
| } | |||
| /*微信商户号**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="微信商户号",name="mchId") | |||
| private String mchId; | |||
| /*支付密钥**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="支付密钥",name="apiKey") | |||
| private String apiKey; | |||
| /*微信回调,支持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; | |||
| public String getMchId() { | |||
| return mchId; | |||
| } | |||
| public void setMchId(String _mchId) { | |||
| mchId = _mchId; | |||
| } | |||
| public String getApiKey() { | |||
| return apiKey; | |||
| } | |||
| public void setApiKey(String _apiKey) { | |||
| apiKey = _apiKey; | |||
| } | |||
| public String getNotifyUrl() { | |||
| return notifyUrl; | |||
| } | |||
| public void setNotifyUrl(String _notifyUrl) { | |||
| notifyUrl = _notifyUrl; | |||
| } | |||
| public String getCertPath() { | |||
| return certPath; | |||
| } | |||
| public void setCertPath(String _certPath) { | |||
| certPath = _certPath; | |||
| } | |||
| public String getPayNotifyUrl() { | |||
| return notifyUrl + "/pay"; | |||
| } | |||
| public String getRefundNotifyUrl() { | |||
| return notifyUrl + "/refund"; | |||
| } | |||
| public String getSeparateNotifyUrl() { | |||
| return notifyUrl + "/separate"; | |||
| } | |||
| public static enum Field | |||
| { | |||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||
| ,MchId_ASC("`mchId` ASC"),MchId_DESC("`mchId` DESC") | |||
| ,ApiKey_ASC("`apiKey` ASC"),ApiKey_DESC("`apiKey` DESC") | |||
| ,NotifyUrl_ASC("`notifyUrl` ASC"),NotifyUrl_DESC("`notifyUrl` DESC") | |||
| ,CertPath_ASC("`certPath` ASC"),CertPath_DESC("`certPath` 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(WxPayAccount.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)); | |||
| } | |||
| } | |||
| } | |||
| @@ -43,7 +43,7 @@ public class WxPayOrder implements Serializable { | |||
| /***/ | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="tenantId") | |||
| private Long tenantId; | |||
| private String tenantId; | |||
| /*创建时间**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createTime") | |||
| private Date createTime; | |||
| @@ -83,10 +83,10 @@ public class WxPayOrder implements Serializable { | |||
| /*支付失败原因**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="支付失败原因",name="failReason") | |||
| private String failReason; | |||
| public Long getTenantId() { | |||
| public String getTenantId() { | |||
| return tenantId; | |||
| } | |||
| public void setTenantId(Long _tenantId) { | |||
| public void setTenantId(String _tenantId) { | |||
| tenantId = _tenantId; | |||
| } | |||
| public Date getCreateTime() { | |||
| @@ -0,0 +1,252 @@ | |||
| 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_refund_order") | |||
| public class WxRefundOrder 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; | |||
| /*创建时间**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createTime") | |||
| private Date createTime; | |||
| /*更新时间**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateTime") | |||
| private Date updateTime; | |||
| /*微信生成的订单号**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="微信生成的订单号",name="transactionId") | |||
| private String transactionId; | |||
| /*订单ID-out_trade_no**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="订单ID-out_trade_no",name="orderId") | |||
| private Long orderId; | |||
| /*支付订单号**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="支付订单号",name="payOrderNo") | |||
| private String payOrderNo; | |||
| /*用户ID**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="用户ID",name="cUserId") | |||
| private Long cUserId; | |||
| /*订单总金额(分)**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="订单总金额(分)",name="totalFee") | |||
| private Integer totalFee; | |||
| /*退款总金额**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="退款总金额",name="refundFee") | |||
| private Integer refundFee; | |||
| /*退款发起时间(秒)**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="退款发起时间(秒)",name="refundTimeStart") | |||
| private Integer refundTimeStart; | |||
| /*退款结束时间(秒)**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="退款结束时间(秒)",name="refundTimeEnd") | |||
| private Integer refundTimeEnd; | |||
| /*支付渠道: 0-微信 1-支付宝 2-银联 **/ | |||
| @io.swagger.annotations.ApiModelProperty(value="支付渠道: 0-微信 1-支付宝 2-银联 ",name="refundVendor") | |||
| private Integer refundVendor; | |||
| /*支付状态: 0-退款中;1-退款成功;2-退款失败**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="支付状态: 0-退款中;1-退款成功;2-退款失败",name="refundOrderStatus") | |||
| private Integer refundOrderStatus; | |||
| /*微信退款单号**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="微信退款单号",name="refundId") | |||
| private String refundId; | |||
| /*支付失败原因**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="支付失败原因",name="failReason") | |||
| private String failReason; | |||
| public String getTenantId() { | |||
| return tenantId; | |||
| } | |||
| public void setTenantId(String _tenantId) { | |||
| tenantId = _tenantId; | |||
| } | |||
| public Date getCreateTime() { | |||
| return createTime; | |||
| } | |||
| public void setCreateTime(Date _createTime) { | |||
| createTime = _createTime; | |||
| } | |||
| public Date getUpdateTime() { | |||
| return updateTime; | |||
| } | |||
| public void setUpdateTime(Date _updateTime) { | |||
| updateTime = _updateTime; | |||
| } | |||
| public String getTransactionId() { | |||
| return transactionId; | |||
| } | |||
| public void setTransactionId(String _transactionId) { | |||
| transactionId = _transactionId; | |||
| } | |||
| public Long getOrderId() { | |||
| return orderId; | |||
| } | |||
| public void setOrderId(Long _orderId) { | |||
| orderId = _orderId; | |||
| } | |||
| public String getPayOrderNo() { | |||
| return payOrderNo; | |||
| } | |||
| public void setPayOrderNo(String _payOrderNo) { | |||
| payOrderNo = _payOrderNo; | |||
| } | |||
| public Long getCUserId() { | |||
| return cUserId; | |||
| } | |||
| public void setCUserId(Long _cUserId) { | |||
| cUserId = _cUserId; | |||
| } | |||
| public Integer getTotalFee() { | |||
| return totalFee; | |||
| } | |||
| public void setTotalFee(Integer _totalFee) { | |||
| totalFee = _totalFee; | |||
| } | |||
| public Integer getRefundFee() { | |||
| return refundFee; | |||
| } | |||
| public void setRefundFee(Integer _refundFee) { | |||
| refundFee = _refundFee; | |||
| } | |||
| public Integer getRefundTimeStart() { | |||
| return refundTimeStart; | |||
| } | |||
| public void setRefundTimeStart(Integer _refundTimeStart) { | |||
| refundTimeStart = _refundTimeStart; | |||
| } | |||
| public Integer getRefundTimeEnd() { | |||
| return refundTimeEnd; | |||
| } | |||
| public void setRefundTimeEnd(Integer _refundTimeEnd) { | |||
| refundTimeEnd = _refundTimeEnd; | |||
| } | |||
| public Integer getRefundVendor() { | |||
| return refundVendor; | |||
| } | |||
| public void setRefundVendor(Integer _refundVendor) { | |||
| refundVendor = _refundVendor; | |||
| } | |||
| public Integer getRefundOrderStatus() { | |||
| return refundOrderStatus; | |||
| } | |||
| public void setRefundOrderStatus(Integer _refundOrderStatus) { | |||
| refundOrderStatus = _refundOrderStatus; | |||
| } | |||
| public String getRefundId() { | |||
| return refundId; | |||
| } | |||
| public void setRefundId(String _refundId) { | |||
| refundId = _refundId; | |||
| } | |||
| public String getFailReason() { | |||
| return failReason; | |||
| } | |||
| public void setFailReason(String _failReason) { | |||
| failReason = _failReason; | |||
| } | |||
| 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") | |||
| ,TransactionId_ASC("`transactionId` ASC"),TransactionId_DESC("`transactionId` DESC") | |||
| ,OrderId_ASC("`orderId` ASC"),OrderId_DESC("`orderId` DESC") | |||
| ,PayOrderNo_ASC("`payOrderNo` ASC"),PayOrderNo_DESC("`payOrderNo` DESC") | |||
| ,CUserId_ASC("`cUserId` ASC"),CUserId_DESC("`cUserId` DESC") | |||
| ,TotalFee_ASC("`totalFee` ASC"),TotalFee_DESC("`totalFee` DESC") | |||
| ,RefundFee_ASC("`refundFee` ASC"),RefundFee_DESC("`refundFee` DESC") | |||
| ,RefundTimeStart_ASC("`refundTimeStart` ASC"),RefundTimeStart_DESC("`refundTimeStart` DESC") | |||
| ,RefundTimeEnd_ASC("`refundTimeEnd` ASC"),RefundTimeEnd_DESC("`refundTimeEnd` DESC") | |||
| ,RefundVendor_ASC("`refundVendor` ASC"),RefundVendor_DESC("`refundVendor` DESC") | |||
| ,RefundOrderStatus_ASC("`refundOrderStatus` ASC"),RefundOrderStatus_DESC("`refundOrderStatus` DESC") | |||
| ,RefundId_ASC("`refundId` ASC"),RefundId_DESC("`refundId` DESC") | |||
| ,FailReason_ASC("`failReason` ASC"),FailReason_DESC("`failReason` 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(WxRefundOrder.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,39 @@ | |||
| package com.simple.enums; | |||
| /** | |||
| * Created by Stormeye on 2018/08/09. | |||
| */ | |||
| public enum EnumRefundStatus { | |||
| REFUND_UNKNOWN(-1, "未知"), | |||
| REFUND_WAIT(0, "退款中"), | |||
| REFUND_REQ_SUCCESS(1, "退款申请成功"), | |||
| REFUND_REQ_FAIL(2, "退款申请失败"), | |||
| REFUND_SUCCESS(3, "退款成功"), | |||
| REFUND_FAIL(4, "退款失败"), | |||
| ; | |||
| public static EnumRefundStatus getEnum(Integer code) { | |||
| for (EnumRefundStatus value : values()) { | |||
| if (value.getCode().equals(code)) { | |||
| return value; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| private Integer code; | |||
| private String message; | |||
| EnumRefundStatus(Integer code, String message) { | |||
| this.code = code; | |||
| this.message = message; | |||
| } | |||
| public Integer getCode() { | |||
| return code; | |||
| } | |||
| public String getMessage() { | |||
| return message; | |||
| } | |||
| } | |||
| @@ -5,7 +5,7 @@ import com.simple.common.CommonMapper; | |||
| import org.apache.ibatis.annotations.Param; | |||
| import com.simple.domain.po.WxAppinfo; | |||
| public interface WxAppinfoMapper extends CommonMapper<WxAppinfo, String> { | |||
| public interface WxAppinfoMapper extends CommonMapper<WxAppinfo, Long> { | |||
| List<WxAppinfo> findList(WxAppinfo wxAppinfo); | |||
| @@ -5,13 +5,10 @@ import com.simple.common.CommonMapper; | |||
| import org.apache.ibatis.annotations.Param; | |||
| import com.simple.domain.po.WxMall; | |||
| public interface WxMallMapper extends CommonMapper<WxMall, String> { | |||
| public interface WxMallMapper extends CommonMapper<WxMall, Long> { | |||
| List<WxMall> findList(WxMall wxMall); | |||
| } | |||
| @@ -5,7 +5,7 @@ import com.simple.common.CommonMapper; | |||
| import org.apache.ibatis.annotations.Param; | |||
| import com.simple.domain.po.WxMerchant; | |||
| public interface WxMerchantMapper extends CommonMapper<WxMerchant, String> { | |||
| public interface WxMerchantMapper extends CommonMapper<WxMerchant, Long> { | |||
| List<WxMerchant> findList(WxMerchant wxMerchant); | |||
| @@ -6,7 +6,7 @@ import com.simple.domain.vo.OrderVo; | |||
| import org.apache.ibatis.annotations.Param; | |||
| import com.simple.domain.po.WxOrder; | |||
| public interface WxOrderMapper extends CommonMapper<WxOrder, String> { | |||
| public interface WxOrderMapper extends CommonMapper<WxOrder, Long> { | |||
| List<WxOrder> findList(WxOrder wxOrder); | |||
| @@ -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.WxPayAccount; | |||
| public interface WxPayAccountMapper extends CommonMapper<WxPayAccount, Long> { | |||
| List<WxPayAccount> findList(WxPayAccount wxPayAccount); | |||
| } | |||
| @@ -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.WxRefundOrder; | |||
| public interface WxRefundOrderMapper extends CommonMapper<WxRefundOrder, Long> { | |||
| List<WxRefundOrder> findList(WxRefundOrder wxRefundOrder); | |||
| } | |||
| @@ -37,6 +37,9 @@ public class WxPay { | |||
| // 查询企业付款 | |||
| private static final String GETTRANSFERINFO_URL = "https://api.mch.weixin.qq.com/mmpaymkttransfers/gettransferinfo"; | |||
| // 沙箱 | |||
| private static final String SANDBOX_GETSIGNKEY_URL = "https://api.mch.weixin.qq.com/sandboxnew/pay/getsignkey"; | |||
| private WxPay() { | |||
| } | |||
| @@ -277,6 +280,17 @@ public class WxPay { | |||
| return qrCodeUrl; | |||
| } | |||
| /** | |||
| * 获取验签秘钥API | |||
| * https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=23_1 | |||
| * | |||
| * @param params | |||
| * @return | |||
| */ | |||
| public static String sanboxSignGet(Map<String, String> params) { | |||
| return doPost(SANDBOX_GETSIGNKEY_URL, params); | |||
| } | |||
| public static String doPost(String url, Map<String, String> params) { | |||
| return HttpUtil.payPost(url, WxPayment.toXml(params)); | |||
| } | |||
| @@ -1,9 +1,6 @@ | |||
| package com.simple.pay; | |||
| import com.simple.utils.HashUtil; | |||
| import com.simple.utils.Utility; | |||
| import com.simple.utils.XmlUtil; | |||
| import org.apache.commons.codec.Charsets; | |||
| import com.simple.utils.*; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import java.io.UnsupportedEncodingException; | |||
| @@ -243,6 +240,35 @@ public class WxPayment { | |||
| return buildSignAfterParasMap(params, paternerKey); | |||
| } | |||
| /** | |||
| * 查询退款 | |||
| * | |||
| * @param appid | |||
| * @param mch_id | |||
| * @param out_trade_no | |||
| * @param paternerKey | |||
| * @return | |||
| */ | |||
| public static Map<String, String> buildWeappRefundQueryMap(String appid, String 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("mch_id", 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); | |||
| } | |||
| /** | |||
| * 组装签名的字段 | |||
| * | |||
| @@ -400,4 +426,21 @@ public class WxPayment { | |||
| } | |||
| return str; | |||
| } | |||
| public static void main(String[] args) { | |||
| Map map = MapUtil.getOrderMap(); | |||
| map.put("mch_id", "1451696902"); | |||
| map.put("nonce_str", RandomUtils.getStr(32)); | |||
| String sign = WxPayment.createSign(map, "9f779d18a174f83879be48574afcb6f6"); | |||
| map.put("sign", sign); | |||
| String response = WxPay.sanboxSignGet(map); | |||
| System.out.println(response); | |||
| /* | |||
| <xml> | |||
| <return_code><![CDATA[SUCCESS]]></return_code> | |||
| <return_msg><![CDATA[ok]]></return_msg> | |||
| <sandbox_signkey><![CDATA[eb68c9a387f33b3a94ab375b2ca30816]]></sandbox_signkey> | |||
| </xml> | |||
| */ | |||
| } | |||
| } | |||
| @@ -3,11 +3,12 @@ package com.simple.pay; | |||
| /** | |||
| * Created by Stormeye on 2018/8/10. | |||
| */ | |||
| public class WxRefundOrder { | |||
| public class WxRefundOrderP { | |||
| private String appid; // 公众账号ID | |||
| private String 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; // 支付金额 | |||
| @@ -45,6 +46,14 @@ public class WxRefundOrder { | |||
| 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; | |||
| } | |||
| @@ -43,11 +43,17 @@ public interface WxCouponOrderService { | |||
| * 根据主键Id(券码)核销 | |||
| * | |||
| * @param id | |||
| * @param mallUserInfo 核销人(登录用户) | |||
| * @param mallUserInfo 核销人(登录用户) | |||
| */ | |||
| ResultData verify(Long id, MallUserInfo mallUserInfo); | |||
| /** | |||
| * 根据主键Id(券码)退券(款) | |||
| * | |||
| * @param id | |||
| * @param mallUserInfo 退券(款)人(登录用户) | |||
| */ | |||
| ResultData refund(Long id, MallUserInfo mallUserInfo); | |||
| @@ -37,12 +37,8 @@ public interface WxMerchantService { | |||
| * @param id | |||
| */ | |||
| void deleteById(Long id); | |||
| void saveOrUpdate(WxMerchant wxMerchant, String shopids, String userids); | |||
| } | |||
| @@ -0,0 +1,48 @@ | |||
| package com.simple.service; | |||
| import java.util.*; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.simple.domain.po.WxPayAccount; | |||
| public interface WxPayAccountService { | |||
| /** | |||
| * 根据实体查询分页列表 | |||
| * | |||
| * @param record | |||
| * @param offset | |||
| * @param limit | |||
| * @return | |||
| */ | |||
| PageInfo<WxPayAccount> listAsPage(WxPayAccount record, Integer pageIndex, Integer pageSize); | |||
| /** | |||
| * 根据Id获得实体 | |||
| * | |||
| * @param id | |||
| * @return | |||
| */ | |||
| WxPayAccount getById(Long id); | |||
| /** | |||
| * 保存或更新实体 | |||
| * | |||
| * @param record | |||
| */ | |||
| void saveOrUpdate(WxPayAccount record); | |||
| /** | |||
| * 根据Id删除实体 | |||
| * | |||
| * @param id | |||
| */ | |||
| void deleteById(Long id); | |||
| } | |||
| @@ -19,8 +19,6 @@ public interface WxPayOrderService { | |||
| */ | |||
| ResultData createPayOrder(WxAppinfo appInfo, WxCUser user, WxPayOrder record, EnumPayWay payWay); | |||
| void handleOrderPaySuccess(WxPayOrder record, String transactionId); | |||
| /** | |||
| * 异步通知 | |||
| * @param paramMap 异步通知参数 | |||
| @@ -29,6 +27,13 @@ public interface WxPayOrderService { | |||
| */ | |||
| String notify(Map<String, String> paramMap, EnumPayWay payWay); | |||
| /** | |||
| * 支付成功处理 | |||
| * @param record | |||
| * @param transactionId | |||
| */ | |||
| void handleOrderPaySuccess(WxPayOrder record, String transactionId); | |||
| /** | |||
| * 页面回调 | |||
| * @param paramMap 页面通知参数 | |||
| @@ -0,0 +1,90 @@ | |||
| package com.simple.service; | |||
| import java.util.*; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.simple.common.ResultData; | |||
| import com.simple.domain.po.WxAppinfo; | |||
| import com.simple.domain.po.WxRefundOrder; | |||
| import com.simple.enums.EnumPayWay; | |||
| public interface WxRefundOrderService { | |||
| /** | |||
| * 创建退款订单 | |||
| * @param appInfo | |||
| * @param record 退款订单请求 | |||
| * @param payWay | |||
| * @return | |||
| */ | |||
| ResultData createRefundOrder(WxAppinfo appInfo, WxRefundOrder record, EnumPayWay payWay); | |||
| /** | |||
| * 退款订单查询 | |||
| * @param appInfo | |||
| * @param record | |||
| * @return | |||
| */ | |||
| ResultData queryRefundOrder(WxAppinfo appInfo, WxRefundOrder record); | |||
| /** | |||
| * 异步通知 | |||
| * @param paramMap 异步通知参数 | |||
| * @param payWay 支付方式 | |||
| * @return | |||
| */ | |||
| String notify(Map<String, String> paramMap, EnumPayWay payWay); | |||
| /** | |||
| * 处理退款成功 | |||
| * @param record | |||
| * @param transactionId | |||
| * @param refundId | |||
| */ | |||
| void handleRefundSuccess(WxRefundOrder record, String transactionId, String refundId); | |||
| /** | |||
| * 页面回调 | |||
| * @param paramMap 页面通知参数 | |||
| * @param payWay 支付方式 | |||
| * @return | |||
| */ | |||
| void callback(Map<String, String> paramMap, EnumPayWay payWay); | |||
| /** | |||
| * 根据实体查询分页列表 | |||
| * | |||
| * @param record | |||
| * @param pageIndex | |||
| * @param pageSize | |||
| * @return | |||
| */ | |||
| PageInfo<WxRefundOrder> listAsPage(WxRefundOrder record, Integer pageIndex, Integer pageSize); | |||
| /** | |||
| * 根据Id获得实体 | |||
| * | |||
| * @param id | |||
| * @return | |||
| */ | |||
| WxRefundOrder getById(Long id); | |||
| /** | |||
| * 保存或更新实体 | |||
| * | |||
| * @param record | |||
| */ | |||
| void saveOrUpdate(WxRefundOrder record); | |||
| /** | |||
| * 根据Id删除实体 | |||
| * | |||
| * @param id | |||
| */ | |||
| void deleteById(Long id); | |||
| } | |||
| @@ -36,7 +36,7 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||
| public void saveOrUpdate(WxCouponChannel record) { | |||
| if (record.getId() == null) { | |||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||
| IdWorker idWorker = new IdWorker(0, 0); | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| record.setId(idWorker.nextId()); | |||
| wxCouponChannelMapper.insertSelective(record); | |||
| } else { | |||
| @@ -2,15 +2,19 @@ package com.simple.service.impl; | |||
| 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.MallUserInfo; | |||
| import com.simple.domain.po.WxCouponOrder; | |||
| import com.simple.enums.EnumCouponOrderStatus; | |||
| import com.simple.mapper.WxCouponOrderMapper; | |||
| import com.simple.service.WxCouponOrderService; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import org.springframework.transaction.annotation.Propagation; | |||
| import org.springframework.transaction.annotation.Transactional; | |||
| import java.util.Date; | |||
| @@ -20,7 +24,6 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| @Autowired | |||
| WxCouponOrderMapper wxCouponOrderMapper; | |||
| @Override | |||
| public PageInfo<WxCouponOrder> listAsPage(WxCouponOrder record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponOrderMapper.findList(record)); | |||
| @@ -48,7 +51,10 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| wxCouponOrderMapper.deleteByPrimaryKey(id); | |||
| } | |||
| @Override | |||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||
| public ResultData verify(Long id, MallUserInfo mallUserInfo) { | |||
| WxCouponOrder wxCouponOrder = wxCouponOrderMapper.selectByPrimaryKey(id); | |||
| if (wxCouponOrder.getCouponOrderStatus() == 2) { | |||
| @@ -69,5 +75,26 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| } | |||
| @Override | |||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||
| public ResultData refund(Long id, MallUserInfo mallUserInfo) { | |||
| WxCouponOrder wxCouponOrder = wxCouponOrderMapper.selectByPrimaryKey(id); | |||
| if (wxCouponOrder.getCouponOrderStatus().equals(EnumCouponOrderStatus.COUPON_ORDER_OVER_TIME.getCode())) { | |||
| return new ResultData(ErrorCode.COUPON_ORDER_IS_OVER_TIME); | |||
| } | |||
| if (wxCouponOrder.getCouponOrderStatus().equals(EnumCouponOrderStatus.COUPON_ORDER_INVALID.getCode())) { | |||
| return new ResultData(ErrorCode.COUPON_ORDER_IS_INVALID); | |||
| } | |||
| if (wxCouponOrder.getCouponOrderStatus().equals(EnumCouponOrderStatus.COUPON_ORDER_USED.getCode())) { | |||
| return new ResultData(ErrorCode.COUPON_ORDER_IS_USED); | |||
| } | |||
| wxCouponOrder.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_INVALID.getCode()); //3退款,券作废 | |||
| wxCouponOrder.setBUserId(mallUserInfo.getId()); | |||
| wxCouponOrder.setUpdateDate(new Date()); | |||
| wxCouponOrderMapper.updateByPrimaryKeySelective(wxCouponOrder); | |||
| return new ResultData(wxCouponOrder); | |||
| } | |||
| } | |||
| @@ -29,11 +29,12 @@ public class WxMallServiceImpl implements WxMallService { | |||
| @Override | |||
| public void saveOrUpdate(WxMall record) { | |||
| if (record.getMallId() == null) { | |||
| if (record.getId() == null) { | |||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| record.setMallId(idWorker.nextId()); | |||
| record.setTenantId(String.valueOf(idWorker.nextId())); | |||
| Long id = idWorker.nextId(); | |||
| record.setId(id); | |||
| record.setTenantId(String.valueOf(id)); | |||
| wxMallMapper.insertSelective(record); | |||
| } else { | |||
| wxMallMapper.updateByPrimaryKeySelective(record); | |||
| @@ -1,14 +1,24 @@ | |||
| package com.simple.service.impl; | |||
| import java.util.*; | |||
| import com.alibaba.fastjson.JSONArray; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.simple.common.IdWorker; | |||
| import com.simple.domain.po.WxMerchant; | |||
| import com.simple.domain.po.WxMerchantBUser; | |||
| import com.simple.domain.po.WxMerchantShop; | |||
| import com.simple.domain.po.WxShop; | |||
| import com.simple.mapper.WxMerchantBUserMapper; | |||
| import com.simple.mapper.WxMerchantMapper; | |||
| import com.simple.mapper.WxMerchantShopMapper; | |||
| import com.simple.mapper.WxShopMapper; | |||
| import com.simple.service.WxMerchantService; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import com.simple.common.IdWorker; | |||
| import org.springframework.transaction.annotation.Transactional; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| @Service | |||
| public class WxMerchantServiceImpl implements WxMerchantService { | |||
| @@ -16,6 +26,14 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| @Autowired | |||
| WxMerchantMapper wxMerchantMapper; | |||
| @Autowired | |||
| WxShopMapper WxShopMapper; | |||
| @Autowired | |||
| WxMerchantShopMapper wxMerchantShopMapper; | |||
| @Autowired | |||
| WxMerchantBUserMapper wxMerchantBUserMapper; | |||
| @Override | |||
| public PageInfo<WxMerchant> listAsPage(WxMerchant record, Integer pageIndex, Integer pageSize) { | |||
| @@ -33,6 +51,8 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| record.setId(idWorker.nextId()); | |||
| record.setCreateDate(new Date()); | |||
| wxMerchantMapper.insertSelective(record); | |||
| } else { | |||
| wxMerchantMapper.updateByPrimaryKeySelective(record); | |||
| @@ -43,12 +63,123 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| public void deleteById(Long id) { | |||
| wxMerchantMapper.deleteByPrimaryKey(id); | |||
| } | |||
| @Transactional | |||
| @Override | |||
| public void saveOrUpdate(WxMerchant wxMerchant, String shopids, String userids) { | |||
| if (wxMerchant.getId() == null) { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| long merchantid = idWorker.nextId(); | |||
| wxMerchant.setId(merchantid); | |||
| Date date = new Date(); | |||
| wxMerchant.setUpdateDate(date); | |||
| wxMerchant.setCreateDate(date); | |||
| wxMerchantMapper.insertSelective(wxMerchant); | |||
| //保存商户商铺的关联 | |||
| List<Long> shopidlist = JSONArray.parseArray(shopids, Long.class); | |||
| for(Long shopid:shopidlist){ | |||
| WxMerchantShop wxMerchantShop = new WxMerchantShop(); | |||
| wxMerchantShop.setId(idWorker.nextId()); | |||
| wxMerchantShop.setMerchantId(merchantid); | |||
| wxMerchantShop.setShopId(shopid); | |||
| wxMerchantShop.setTenantId(wxMerchant.getTenantId()); | |||
| Date shopdate = new Date(); | |||
| wxMerchantShop.setUpdateDate(shopdate); | |||
| wxMerchantShop.setCreateDate(shopdate); | |||
| wxMerchantShop.setRentalEndDate(shopdate); | |||
| wxMerchantShop.setRentalStartDate(shopdate); | |||
| wxMerchantShopMapper.insertSelective(wxMerchantShop); | |||
| //更新商铺状态 | |||
| WxShop wxShop = new WxShop(); | |||
| wxShop.setId(shopid); | |||
| wxShop.setStatus(1);//已出租 | |||
| WxShopMapper.updateByPrimaryKeySelective(wxShop); | |||
| } | |||
| //保存商户关联用户 | |||
| List<Long> useridlist = JSONArray.parseArray(userids, Long.class); | |||
| for(Long userid:useridlist){ | |||
| WxMerchantBUser wxMerchantBUser = new WxMerchantBUser(); | |||
| wxMerchantBUser.setId(userid); | |||
| List<WxMerchantBUser> buserlist = wxMerchantBUserMapper.findList(wxMerchantBUser); | |||
| if(buserlist.size()>0){ | |||
| wxMerchantBUser = buserlist.get(0); | |||
| wxMerchantBUser.setMerchantId(merchantid); | |||
| wxMerchantBUser.setUpdateDate(new Date()); | |||
| wxMerchantBUserMapper.updateByPrimaryKey(wxMerchantBUser); | |||
| } | |||
| } | |||
| } else { | |||
| //更新商户 | |||
| Date date = new Date(); | |||
| wxMerchant.setUpdateDate(date); | |||
| wxMerchantMapper.updateByPrimaryKeySelective(wxMerchant); | |||
| //删除当前商户关联的所有商铺然后再插入 | |||
| WxMerchantShop wxMerchantShopQuery = new WxMerchantShop(); | |||
| wxMerchantShopQuery.setTenantId(wxMerchant.getTenantId()); | |||
| wxMerchantShopQuery.setMerchantId(wxMerchant.getId()); | |||
| List<WxMerchantShop> wxMerchantShopList = wxMerchantShopMapper.findList(wxMerchantShopQuery); | |||
| for(WxMerchantShop merchantShop:wxMerchantShopList){ | |||
| wxMerchantShopMapper.delete(merchantShop); | |||
| //更新商铺状态 | |||
| WxShop wxShop = new WxShop(); | |||
| wxShop.setId(merchantShop.getShopId()); | |||
| wxShop.setStatus(0);//已出租 | |||
| WxShopMapper.updateByPrimaryKeySelective(wxShop); | |||
| } | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| //保存商户商铺的关联 | |||
| List<Long> shopidlist = JSONArray.parseArray(shopids, Long.class); | |||
| for(Long shopid:shopidlist){ | |||
| WxMerchantShop wxMerchantShop = new WxMerchantShop(); | |||
| wxMerchantShop.setId(idWorker.nextId()); | |||
| wxMerchantShop.setMerchantId(wxMerchant.getId()); | |||
| wxMerchantShop.setShopId(shopid); | |||
| wxMerchantShop.setTenantId(wxMerchant.getTenantId()); | |||
| Date shopdate = new Date(); | |||
| wxMerchantShop.setUpdateDate(shopdate); | |||
| wxMerchantShop.setCreateDate(shopdate); | |||
| wxMerchantShop.setRentalEndDate(shopdate); | |||
| wxMerchantShop.setRentalStartDate(shopdate); | |||
| wxMerchantShopMapper.insertSelective(wxMerchantShop); | |||
| //更新商铺状态 | |||
| WxShop wxShop = new WxShop(); | |||
| wxShop.setId(shopid); | |||
| wxShop.setStatus(1);//已出租 | |||
| WxShopMapper.updateByPrimaryKeySelective(wxShop); | |||
| } | |||
| //保存商户关联用户 | |||
| List<Long> useridlist = JSONArray.parseArray(userids, Long.class); | |||
| for(Long userid:useridlist){ | |||
| WxMerchantBUser wxMerchantBUser = new WxMerchantBUser(); | |||
| wxMerchantBUser.setId(userid); | |||
| List<WxMerchantBUser> buserlist = wxMerchantBUserMapper.findList(wxMerchantBUser); | |||
| if(buserlist.size()>0){ | |||
| wxMerchantBUser = buserlist.get(0); | |||
| wxMerchantBUser.setMerchantId(wxMerchant.getId()); | |||
| wxMerchantBUser.setUpdateDate(new Date()); | |||
| wxMerchantBUserMapper.updateByPrimaryKey(wxMerchantBUser); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -6,21 +6,16 @@ import java.util.*; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.simple.common.ErrorCode; | |||
| import com.simple.domain.po.WxCUser; | |||
| import com.simple.domain.po.WxCoupon; | |||
| import com.simple.domain.po.WxCouponOrder; | |||
| import com.simple.domain.po.WxOrder; | |||
| import com.simple.domain.po.*; | |||
| import com.simple.domain.vo.OrderVo; | |||
| import com.simple.enums.EnumCouponOrderStatus; | |||
| import com.simple.enums.EnumOrderStatus; | |||
| import com.simple.enums.EnumPayType; | |||
| import com.simple.enums.EnumValidStatus; | |||
| import com.simple.exception.MallinkException; | |||
| import com.simple.mapper.WxCUserMapper; | |||
| import com.simple.mapper.WxCouponMapper; | |||
| import com.simple.mapper.WxCouponOrderMapper; | |||
| import com.simple.mapper.WxOrderMapper; | |||
| import com.simple.mapper.*; | |||
| import com.simple.service.WxOrderService; | |||
| import com.simple.service.WxPayAccountService; | |||
| import com.simple.utils.RedisLock; | |||
| import org.apache.log4j.Logger; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| @@ -37,6 +32,18 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| @Autowired | |||
| RedisLock redisLock; | |||
| @Autowired | |||
| WxAppinfoMapper wxAppinfoMapper; | |||
| @Autowired | |||
| WxPayAccountMapper wxPayAccountMapper; | |||
| @Autowired | |||
| WxMallMapper wxMallMapper; | |||
| @Autowired | |||
| WxMerchantMapper wxMerchantMapper; | |||
| @Autowired | |||
| WxCUserMapper wxCUserMapper; | |||
| @@ -87,22 +94,41 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| Date curr = new Date(); | |||
| Date valid_date = null; | |||
| // 检查 优惠券 库存 | |||
| if (coupon.getRemainInventory() <= 0) { | |||
| //解锁 | |||
| redisLock.unlock(couponIdStr, timeStr); | |||
| logger.error("此券库存为0, couponId: " + couponIdStr); | |||
| throw new MallinkException(ErrorCode.REMAIN_IS_EMPTY); | |||
| } | |||
| // check 购买是否超限 | |||
| try { | |||
| // 检查 优惠券 库存 | |||
| if (coupon.getRemainInventory() <= 0) { | |||
| WxCouponOrder query = new WxCouponOrder(); | |||
| query.setCouponId(couponId); | |||
| query.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USE_WAIT.getCode()); | |||
| List<WxCouponOrder> list = wxCouponOrderMapper.findList(query); | |||
| if (list.size() >= coupon.getUseLimitQuantity()) { | |||
| //解锁 | |||
| redisLock.unlock(couponIdStr, timeStr); | |||
| logger.error("此券库存为0, couponId: " + couponIdStr); | |||
| throw new MallinkException(ErrorCode.REMAIN_IS_EMPTY); | |||
| throw new MallinkException(ErrorCode.ORDER_IS_LIMITED); | |||
| } | |||
| }catch (Exception e) { | |||
| //解锁 | |||
| redisLock.unlock(couponIdStr, timeStr); | |||
| logger.error("此券购买数量检查出问题了, couponId: " + couponIdStr); | |||
| throw new MallinkException(ErrorCode.ORDER_IS_FAIL); | |||
| } | |||
| try { | |||
| // 减库存 | |||
| coupon.setRemainInventory(coupon.getRemainInventory() - 1); | |||
| wxCouponMapper.updateByPrimaryKeySelective(coupon); | |||
| //解锁 | |||
| redisLock.unlock(couponIdStr, timeStr); | |||
| } catch (RuntimeException e) { | |||
| //解锁 | |||
| redisLock.unlock(couponIdStr, timeStr); | |||
| logger.error("此券减库存失败, couponId: " + couponIdStr); | |||
| throw new MallinkException(ErrorCode.ORDER_IS_FAIL); | |||
| } | |||
| @@ -110,22 +136,29 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| payPrice = coupon.getSalePrice(); | |||
| payment = coupon.getSalePrice(); | |||
| valid_date = (coupon.getValidType() == EnumValidStatus.VALID_RANGE.getCode())?coupon.getValidEndDate(): new Date((curr.getTime()/1000+coupon.getValidDays()*24*60*60)*1000); | |||
| valid_date = (coupon.getValidType() == EnumValidStatus.VALID_RANGE.getCode())? | |||
| coupon.getValidEndDate(): | |||
| new Date((curr.getTime()/1000+coupon.getValidDays()*24*60*60)*1000); | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| Long orderNumber = idWorker.nextId(); | |||
| WxOrder record = new WxOrder(); | |||
| // body | |||
| // tenant_id + merchant_id + title + subtitle | |||
| String bodyStr = coupon.getTitle() + "/" + coupon.getSubTitle(); | |||
| WxOrder record = new WxOrder(); | |||
| try { | |||
| // 保存订单 | |||
| record.setId(orderNumber); | |||
| record.setTenantId(user.getTenantId()); | |||
| record.setOrderNumber(orderNumber); | |||
| record.setCUserId(user.getId()); | |||
| record.setPaymentType(EnumPayType.PAY_PAYMENT.getCode()); | |||
| record.setPayment(payment); | |||
| record.setOrderStatus(EnumOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode()); | |||
| record.setDetail(bodyStr); | |||
| record.setCreateDate(curr); | |||
| record.setUpdateDate(curr); | |||
| wxOrderMapper.insertSelective(record); | |||
| @@ -166,37 +199,41 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND); | |||
| } | |||
| Date currentDate = new Date(); | |||
| /* | |||
| // 0:待付款 | |||
| // 1:已支付 | |||
| if (enumOrderStatus == EnumOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS) { | |||
| updateRecord.setPaymentTime(currentDate); | |||
| } | |||
| // 2:已取消, 库存加1 | |||
| if (enumOrderStatus == EnumOrderStatus.ORDER_STATUS_OVERTIME_CANCEL) { | |||
| WxCoupon coupon = wxCouponMapper.selectByPrimaryKey(updateRecord.getCouponId()); | |||
| if (coupon.getRemainInventory() <= 0) { | |||
| logger.error("coupon not found, couponId: " + updateRecord.getCouponId()); | |||
| throw new MallinkException(ErrorCode.REMAIN_IS_EMPTY); | |||
| switch (enumOrderStatus) { | |||
| case ORDER_STATUS_PAYMENT_SUCCESS: { | |||
| // 已支付,更新支付时间 | |||
| updateRecord.setPaymentTime(currentDate); | |||
| break; | |||
| } | |||
| coupon.setRemainInventory(coupon.getRemainInventory() + 1); | |||
| wxCouponMapper.updateByPrimaryKeySelective(coupon); | |||
| } | |||
| // 3:待退款 | |||
| // 4:已退款 | |||
| if (enumOrderStatus == EnumOrderStatus.ORDER_STATUS_REFUND_SUCCESS) { | |||
| WxCoupon coupon = wxCouponMapper.selectByPrimaryKey(updateRecord.getCouponId()); | |||
| if (coupon.getRemainInventory() <= 0) { | |||
| logger.error("coupon not found, couponId: " + updateRecord.getCouponId()); | |||
| throw new MallinkException(ErrorCode.REMAIN_IS_EMPTY); | |||
| case ORDER_STATUS_OVERTIME_CANCEL: | |||
| case ORDER_STATUS_REFUND_SUCCESS: | |||
| { | |||
| // 已取消/已退款,库存加1 | |||
| // 获取订单相关coupon | |||
| WxCouponOrder couponOrder = new WxCouponOrder(); | |||
| couponOrder.setOrderId(orderId); | |||
| List<WxCouponOrder> colist = wxCouponOrderMapper.findList(couponOrder); | |||
| for(WxCouponOrder couponOrderX : colist) { | |||
| String couponIdStr = String.valueOf(couponOrderX.getCouponId()); | |||
| //加锁 | |||
| long time = System.currentTimeMillis() + RedisLock.TIMEOUT; | |||
| String timeStr = String.valueOf(time); | |||
| if(!redisLock.lock(couponIdStr, timeStr)) { | |||
| logger.error("此券被锁定, couponId: " + couponIdStr); | |||
| throw new MallinkException(ErrorCode.TOO_MANY_REQUEST); | |||
| } | |||
| WxCoupon coupon = wxCouponMapper.selectByPrimaryKey(couponOrderX.getCouponId()); | |||
| coupon.setRemainInventory(coupon.getRemainInventory() + 1); | |||
| wxCouponMapper.updateByPrimaryKeySelective(coupon); | |||
| //解锁 | |||
| redisLock.unlock(couponIdStr, timeStr); | |||
| } | |||
| break; | |||
| } | |||
| coupon.setRemainInventory(coupon.getRemainInventory() + 1); | |||
| wxCouponMapper.updateByPrimaryKeySelective(coupon); | |||
| } | |||
| // 5:退款失败 | |||
| updateRecord.setStatus(enumOrderStatus.getCode()); | |||
| updateRecord.setOrderStatus(enumOrderStatus.getCode()); | |||
| updateRecord.setUpdateDate(currentDate); | |||
| */ | |||
| return wxOrderMapper.updateByPrimaryKey(updateRecord); | |||
| } | |||
| @@ -209,7 +246,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| public void saveOrUpdate(WxOrder record) { | |||
| if (record.getId() == null) { | |||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||
| IdWorker idWorker = new IdWorker(0, 0); | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| record.setId(idWorker.nextId()); | |||
| wxOrderMapper.insertSelective(record); | |||
| } else { | |||
| @@ -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.WxPayAccount; | |||
| import com.simple.mapper.WxPayAccountMapper; | |||
| import com.simple.service.WxPayAccountService; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import com.simple.common.IdWorker; | |||
| @Service | |||
| public class WxPayAccountServiceImpl implements WxPayAccountService { | |||
| @Autowired | |||
| WxPayAccountMapper wxPayAccountMapper; | |||
| @Override | |||
| public PageInfo<WxPayAccount> listAsPage(WxPayAccount record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxPayAccountMapper.findList(record)); | |||
| } | |||
| @Override | |||
| public WxPayAccount getById(Long id) { | |||
| return wxPayAccountMapper.selectByPrimaryKey(id); | |||
| } | |||
| @Override | |||
| public void saveOrUpdate(WxPayAccount record) { | |||
| if (record.getId() == null) { | |||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| record.setId(idWorker.nextId()); | |||
| wxPayAccountMapper.insertSelective(record); | |||
| } else { | |||
| wxPayAccountMapper.updateByPrimaryKeySelective(record); | |||
| } | |||
| } | |||
| @Override | |||
| public void deleteById(Long id) { | |||
| wxPayAccountMapper.deleteByPrimaryKey(id); | |||
| } | |||
| } | |||
| @@ -1,24 +1,21 @@ | |||
| package com.simple.service.impl; | |||
| import java.math.BigDecimal; | |||
| import java.util.*; | |||
| import cn.binarywang.wx.miniapp.api.WxMaService; | |||
| 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.WxCUser; | |||
| import com.simple.domain.po.WxOrder; | |||
| import com.simple.domain.po.WxPayOrder; | |||
| import com.simple.domain.po.*; | |||
| import com.simple.enums.EnumOrderStatus; | |||
| import com.simple.enums.EnumPayStatus; | |||
| import com.simple.enums.EnumPayWay; | |||
| import com.simple.exception.MallinkException; | |||
| import com.simple.mapper.WxAppinfoMapper; | |||
| import com.simple.mapper.WxOrderMapper; | |||
| import com.simple.mapper.WxPayAccountMapper; | |||
| import com.simple.mapper.WxPayOrderMapper; | |||
| import com.simple.pay.WxPay; | |||
| import com.simple.pay.WxPayOrderP; | |||
| @@ -26,6 +23,7 @@ import com.simple.pay.WxPayment; | |||
| 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 org.apache.log4j.Logger; | |||
| @@ -40,6 +38,12 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| private Logger logger = Logger.getLogger(getClass()); | |||
| @Autowired | |||
| WxAppinfoMapper wxAppinfoMapper; | |||
| @Autowired | |||
| WxPayAccountMapper wxPayAccountMapper; | |||
| @Autowired | |||
| WxOrderMapper wxOrderMapper; | |||
| @@ -80,18 +84,18 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| logger.warn("pay order, order status not allow, repaymentReq: " + order.toString() + " , payWay: " + payWay.toString()); | |||
| throw new MallinkException(ErrorCode.ORDER_IS_NOT_PAY); | |||
| } | |||
| // TODO body | |||
| String body = "test"; | |||
| // 2. check 是否有支付订单 | |||
| List<WxPayOrder> list = wxPayOrderMapper.findList(record); | |||
| if (list.size() > 0) { | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_EXIST); | |||
| } | |||
| // 3. 创建支付订单 | |||
| Long id = idworker.nextId(); | |||
| Date currentDate = new Date(); | |||
| Long id = idworker.nextId(); | |||
| record.setId(id); | |||
| record.setTenantId(user.getTenantId()); | |||
| record.setCUserId(user.getId()); | |||
| record.setCreateTime(currentDate); | |||
| record.setUpdateTime(currentDate); | |||
| int currentTime = Utility.convertDate2TimeStamp(currentDate); | |||
| @@ -104,26 +108,28 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| record.setPayOrderStatus(EnumPayStatus.PAY_WAY_WAIT.getCode()); | |||
| int sqlRow = wxPayOrderMapper.insertSelective(record); | |||
| if(sqlRow == 1) { | |||
| if(sqlRow != 1) { | |||
| throw new MallinkException(ErrorCode.DB_FAIL); | |||
| } | |||
| WxPayAccount payAccount = wxPayAccountMapper.selectByPrimaryKey(appInfo.getPayId()); | |||
| { | |||
| // 统一下单 | |||
| String noncestr = Utility.generate32UUID(); | |||
| WxPayOrderP wxPayOrderP = new WxPayOrderP(); | |||
| wxPayOrderP.setAppid(appInfo.getAppId()); | |||
| wxPayOrderP.setMch_id(appInfo.getMchId()); | |||
| wxPayOrderP.setOpenid(user.getOpenId()); | |||
| wxPayOrderP.setAppid(user.getAppId()); | |||
| wxPayOrderP.setMch_id(payAccount.getMchId()); | |||
| wxPayOrderP.setNonce_str(noncestr); | |||
| wxPayOrderP.setBody(body); | |||
| 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(appInfo.getNotifyUrl()); | |||
| wxPayOrderP.setTrade_type(WxPay.TradeType.APP.name()); // 终端类型 | |||
| 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(currentTime)); | |||
| wxPayOrderP.setTime_start(Utility.getDataFormatStringYYYYMMDDHHmmss(currentTime + 15 * 60)); // 15分钟结束 | |||
| wxPayOrderP.setSign(WxPayment.createSign(BeanUtils.toStringMap(wxPayOrderP), appInfo.getSecret())); | |||
| wxPayOrderP.setTime_expire(Utility.getDataFormatStringYYYYMMDDHHmmss(currentTime + 15 * 60)); // 15分钟结束 | |||
| wxPayOrderP.setSign(WxPayment.createSign(BeanUtils.toStringMap(wxPayOrderP), payAccount.getApiKey())); | |||
| String response = WxPay.pushOrder(BeanUtils.toStringMap(wxPayOrderP)); | |||
| logger.info("pay order, wechat pushOrder, wxPayOrder:" + wxPayOrderP.toString() + ", response: " + response.toString()); | |||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||
| @@ -131,12 +137,13 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| if ("SUCCESS".equals(result_no)) { | |||
| String prepay_id = returnMap.get("prepay_id"); | |||
| String timestamp = String.valueOf(Utility.getCurrentTimeStamp()); | |||
| Map<String, String> sighMap = new HashMap<>(); | |||
| 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); | |||
| String signAgent = WxPayment.createSign(sighMap, appInfo.getSecret()); | |||
| 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); | |||
| @@ -154,12 +161,30 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| } | |||
| } | |||
| // TODO | |||
| // 微信订单查询 | |||
| // 微信关闭订单 | |||
| /** | |||
| * 提供微信支付回调调用 | |||
| * @param paramMap 异步通知参数 | |||
| * @param payWay 支付方式 | |||
| * @return | |||
| */ | |||
| @Override | |||
| public String notify(Map<String, String> paramMap, EnumPayWay payWay) { | |||
| // how to get wechatAppId, wechatMchId, partnerKey | |||
| String wechatAppId = ""; | |||
| String wechatMchId = ""; | |||
| String 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); | |||
| } | |||
| WxPayAccount payAccount = wxPayAccountMapper.selectByPrimaryKey(appinfo.getPayId()); | |||
| if (payAccount == null) { | |||
| throw new MallinkException(ErrorCode.MCH_INFO_NOT_FOUND); | |||
| } | |||
| String partnerKey = payAccount.getApiKey(); | |||
| try { | |||
| if (payWay == EnumPayWay.PAY_WAY_WEAPP) { | |||
| boolean signVerified = false; | |||
| @@ -178,28 +203,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| resultMap.put("return_msg", "订单状态码非SUCCESS"); | |||
| return XmlUtil.parseDto2Xml(resultMap, ""); | |||
| } | |||
| if (!wechatAppId.equals(paramMap.get("appid"))) { | |||
| logger.warn("notify order, wxpay appid is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| Map<String, String> resultMap = new LinkedHashMap<>(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "非法请求appid"); | |||
| return XmlUtil.parseDto2Xml(resultMap, ""); | |||
| } | |||
| if (!(wechatMchId.equals(paramMap.get("mch_id")))) { | |||
| logger.warn("notify order, wxpay mch_id is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| Map<String, String> resultMap = new LinkedHashMap<>(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "非法请求mch_id"); | |||
| return XmlUtil.parseDto2Xml(resultMap, ""); | |||
| } | |||
| if (!"SUCCESS".equals(paramMap.get("result_code"))) { | |||
| logger.warn("notify order, wxpay result_code is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| Map<String, String> resultMap = new LinkedHashMap<>(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "result_code fail"); | |||
| return XmlUtil.parseDto2Xml(resultMap, ""); | |||
| } | |||
| String payOrderNo = paramMap.get("out_trade_no"); | |||
| Long payOrderId = Long.valueOf(payOrderNo); | |||
| WxPayOrder payOrder = wxPayOrderMapper.selectByPrimaryKey(payOrderId); | |||
| @@ -255,18 +259,29 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND); | |||
| } | |||
| Date currentDate = new Date(); | |||
| // 修改支付订单状态 | |||
| try { | |||
| WxPayOrder updatePayOrder = new WxPayOrder(); | |||
| updatePayOrder.setId(record.getId()); | |||
| updatePayOrder.setOrderId(record.getOrderId()); | |||
| updatePayOrder.setUpdateTime(currentDate); | |||
| updatePayOrder.setPayOrderStatus(EnumPayStatus.PAY_WAY_SUCCESS.getCode()); | |||
| updatePayOrder.setTransactionId(transactionId); | |||
| wxPayOrderMapper.updateByPrimaryKeySelective(updatePayOrder); | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| throw new MallinkException(ErrorCode.DB_FAIL); | |||
| } | |||
| // 修改订单状态 | |||
| wxOrderService.updateOrderStatus(order.getId(), EnumOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS); | |||
| try { | |||
| wxOrderService.updateOrderStatus(order.getId(), EnumOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS); | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| throw new MallinkException(ErrorCode.DB_FAIL); | |||
| } | |||
| // 修改支付订单状态 | |||
| Date currentDate = new Date(); | |||
| WxPayOrder updatePayOrder = new WxPayOrder(); | |||
| updatePayOrder.setId(record.getId()); | |||
| updatePayOrder.setOrderId(record.getOrderId()); | |||
| updatePayOrder.setUpdateTime(currentDate); | |||
| updatePayOrder.setPayOrderStatus(EnumPayStatus.PAY_WAY_SUCCESS.getCode()); | |||
| updatePayOrder.setTransactionId(transactionId); | |||
| wxPayOrderMapper.updateByPrimaryKeySelective(updatePayOrder); | |||
| /* | |||
| Map<String, String> msgMap = new HashMap<>(); | |||
| try { | |||
| @@ -0,0 +1,516 @@ | |||
| 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.*; | |||
| import com.simple.enums.EnumOrderStatus; | |||
| import com.simple.enums.EnumPayStatus; | |||
| import com.simple.enums.EnumPayWay; | |||
| import com.simple.enums.EnumRefundStatus; | |||
| 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.service.WxRefundOrderService; | |||
| import com.simple.utils.BeanUtils; | |||
| import com.simple.utils.Utility; | |||
| import com.simple.utils.XmlUtil; | |||
| import org.apache.log4j.Logger; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import com.simple.common.IdWorker; | |||
| import org.springframework.transaction.annotation.Propagation; | |||
| import org.springframework.transaction.annotation.Transactional; | |||
| @Service | |||
| public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||
| private Logger logger = Logger.getLogger(getClass()); | |||
| @Autowired | |||
| WxAppinfoMapper wxAppinfoMapper; | |||
| @Autowired | |||
| WxRefundOrderMapper wxRefundOrderMapper; | |||
| @Autowired | |||
| WxOrderMapper wxOrderMapper; | |||
| @Autowired | |||
| WxPayOrderMapper wxPayOrderMapper; | |||
| @Autowired | |||
| WxPayAccountMapper wxPayAccountMapper; | |||
| JSONObject errorRefundReqMap = JSON.parseObject("{\n" + | |||
| " \"SYSTEMERROR\": {\n" + | |||
| " \"detail\": \"接口返回错误\",\n" + | |||
| " \"reason\": \"系统超时等\",\n" + | |||
| " \"resolution\": \"请不要更换商户退款单号,请使用相同参数再次调用API。\"\n" + | |||
| " },\n" + | |||
| " \"BIZERR_NEED_RETRY\": {\n" + | |||
| " \"detail\": \"退款业务流程错误,需要商户触发重试来解决\",\n" + | |||
| " \"reason\": \"并发情况下,业务被拒绝,商户重试即可解决\",\n" + | |||
| " \"resolution\": \"请不要更换商户退款单号,请使用相同参数再次调用API。\"\n" + | |||
| " },\n" + | |||
| " \"TRADE_OVERDUE\": {\n" + | |||
| " \"detail\": \"订单已经超过退款期限\",\n" + | |||
| " \"reason\": \"订单已经超过可退款的最大期限(支付后一年内可退款)\\t\",\n" + | |||
| " \"resolution\": \"请选择其他方式自行退款\"\n" + | |||
| " },\n" + | |||
| " \"ERROR\": {\n" + | |||
| " \"detail\": \"业务错误\",\n" + | |||
| " \"reason\": \"申请退款业务发生错误\",\n" + | |||
| " \"resolution\": \"该错误都会返回具体的错误原因,请根据实际返回做相应处理。\"\n" + | |||
| " },\n" + | |||
| " \"USER_ACCOUNT_ABNORMAL\": {\n" + | |||
| " \"detail\": \"退款请求失败\",\n" + | |||
| " \"reason\": \"用户帐号注销\",\n" + | |||
| " \"resolution\": \"此状态代表退款申请失败,商户可自行处理退款。\"\n" + | |||
| " },\n" + | |||
| " \"INVALID_REQ_TOO_MUCH\": {\n" + | |||
| " \"detail\": \"无效请求过多\",\n" + | |||
| " \"reason\": \"连续错误请求数过多被系统短暂屏蔽\\t\",\n" + | |||
| " \"resolution\": \"请检查业务是否正常,确认业务正常后请在1分钟后再来重试\"\n" + | |||
| " },\n" + | |||
| " \"NOTENOUGH\": {\n" + | |||
| " \"detail\": \"余额不足\",\n" + | |||
| " \"reason\": \"商户可用退款余额不足\",\n" + | |||
| " \"resolution\": \"此状态代表退款申请失败,商户可根据具体的错误提示做相应的处理。\"\n" + | |||
| " },\n" + | |||
| " \"INVALID_TRANSACTIONID\": {\n" + | |||
| " \"detail\": \"无效transaction_id\",\n" + | |||
| " \"reason\": \"请求参数未按指引进行填写\",\n" + | |||
| " \"resolution\": \"请求参数错误,检查原交易号是否存在或发起支付交易接口返回失败\"\n" + | |||
| " },\n" + | |||
| " \"PARAM_ERROR\": {\n" + | |||
| " \"detail\": \"参数错误\",\n" + | |||
| " \"reason\": \"请求参数未按指引进行填写\",\n" + | |||
| " \"resolution\": \"请求参数错误,请重新检查再调用退款申请\"\n" + | |||
| " },\n" + | |||
| " \"APPID_NOT_EXIST\": {\n" + | |||
| " \"detail\": \"APPID不存在\",\n" + | |||
| " \"reason\": \"参数中缺少APPID\",\n" + | |||
| " \"resolution\": \"请检查APPID是否正确\"\n" + | |||
| " },\n" + | |||
| " \"MCHID_NOT_EXIST\": {\n" + | |||
| " \"detail\": \"MCHID不存在\",\n" + | |||
| " \"reason\": \"参数中缺少MCHID\",\n" + | |||
| " \"resolution\": \"请检查MCHID是否正确\"\n" + | |||
| " },\n" + | |||
| " \"REQUIRE_POST_METHOD\": {\n" + | |||
| " \"detail\": \"请使用post方法\",\n" + | |||
| " \"reason\": \"未使用post传递参数\",\n" + | |||
| " \"resolution\": \"请检查请求参数是否通过post方法提交\"\n" + | |||
| " },\n" + | |||
| " \"SIGNERROR\": {\n" + | |||
| " \"detail\": \"签名错误\",\n" + | |||
| " \"reason\": \"参数签名结果不正确\",\n" + | |||
| " \"resolution\": \"请检查签名参数和方法是否都符合签名算法要求\"\n" + | |||
| " },\n" + | |||
| " \"XML_FORMAT_ERROR\": {\n" + | |||
| " \"detail\": \"XML格式错误\",\n" + | |||
| " \"reason\": \"XML格式错误\",\n" + | |||
| " \"resolution\": \"请检查XML参数格式是否正确\"\n" + | |||
| " },\n" + | |||
| " \"FREQUENCY_LIMITED\": {\n" + | |||
| " \"detail\": \"频率限制\",\n" + | |||
| " \"reason\": \"2个月之前的订单申请退款有频率限制\",\n" + | |||
| " \"resolution\": \"该笔退款未受理,请降低频率后重试\"\n" + | |||
| " }\n" + | |||
| "}"); | |||
| JSONObject errorRefundQueryMap = JSON.parseObject("{\n" + | |||
| " \"SYSTEMERROR\": {\n" + | |||
| " \"detail\": \"接口返回错误\",\n" + | |||
| " \"reason\": \"系统超时等\",\n" + | |||
| " \"resolution\": \"请不要更换商户退款单号,请使用相同参数再次调用API。\"\n" + | |||
| " },\n" + | |||
| " \"BIZERR_NEED_RETRY\": {\n" + | |||
| " \"detail\": \"退款业务流程错误,需要商户触发重试来解决\",\n" + | |||
| " \"reason\": \"并发情况下,业务被拒绝,商户重试即可解决\",\n" + | |||
| " \"resolution\": \"请不要更换商户退款单号,请使用相同参数再次调用API。\"\n" + | |||
| " },\n" + | |||
| " \"TRADE_OVERDUE\": {\n" + | |||
| " \"detail\": \"订单已经超过退款期限\",\n" + | |||
| " \"reason\": \"订单已经超过可退款的最大期限(支付后一年内可退款)\\t\",\n" + | |||
| " \"resolution\": \"请选择其他方式自行退款\"\n" + | |||
| " },\n" + | |||
| " \"ERROR\": {\n" + | |||
| " \"detail\": \"业务错误\",\n" + | |||
| " \"reason\": \"申请退款业务发生错误\",\n" + | |||
| " \"resolution\": \"该错误都会返回具体的错误原因,请根据实际返回做相应处理。\"\n" + | |||
| " },\n" + | |||
| " \"USER_ACCOUNT_ABNORMAL\": {\n" + | |||
| " \"detail\": \"退款请求失败\",\n" + | |||
| " \"reason\": \"用户帐号注销\",\n" + | |||
| " \"resolution\": \"此状态代表退款申请失败,商户可自行处理退款。\"\n" + | |||
| " },\n" + | |||
| " \"INVALID_REQ_TOO_MUCH\": {\n" + | |||
| " \"detail\": \"无效请求过多\",\n" + | |||
| " \"reason\": \"连续错误请求数过多被系统短暂屏蔽\\t\",\n" + | |||
| " \"resolution\": \"请检查业务是否正常,确认业务正常后请在1分钟后再来重试\"\n" + | |||
| " },\n" + | |||
| " \"NOTENOUGH\": {\n" + | |||
| " \"detail\": \"余额不足\",\n" + | |||
| " \"reason\": \"商户可用退款余额不足\",\n" + | |||
| " \"resolution\": \"此状态代表退款申请失败,商户可根据具体的错误提示做相应的处理。\"\n" + | |||
| " },\n" + | |||
| " \"INVALID_TRANSACTIONID\": {\n" + | |||
| " \"detail\": \"无效transaction_id\",\n" + | |||
| " \"reason\": \"请求参数未按指引进行填写\",\n" + | |||
| " \"resolution\": \"请求参数错误,检查原交易号是否存在或发起支付交易接口返回失败\"\n" + | |||
| " },\n" + | |||
| " \"PARAM_ERROR\": {\n" + | |||
| " \"detail\": \"参数错误\",\n" + | |||
| " \"reason\": \"请求参数未按指引进行填写\",\n" + | |||
| " \"resolution\": \"请求参数错误,请重新检查再调用退款申请\"\n" + | |||
| " },\n" + | |||
| " \"APPID_NOT_EXIST\": {\n" + | |||
| " \"detail\": \"APPID不存在\",\n" + | |||
| " \"reason\": \"参数中缺少APPID\",\n" + | |||
| " \"resolution\": \"请检查APPID是否正确\"\n" + | |||
| " },\n" + | |||
| " \"MCHID_NOT_EXIST\": {\n" + | |||
| " \"detail\": \"MCHID不存在\",\n" + | |||
| " \"reason\": \"参数中缺少MCHID\",\n" + | |||
| " \"resolution\": \"请检查MCHID是否正确\"\n" + | |||
| " },\n" + | |||
| " \"REQUIRE_POST_METHOD\": {\n" + | |||
| " \"detail\": \"请使用post方法\",\n" + | |||
| " \"reason\": \"未使用post传递参数\",\n" + | |||
| " \"resolution\": \"请检查请求参数是否通过post方法提交\"\n" + | |||
| " },\n" + | |||
| " \"SIGNERROR\": {\n" + | |||
| " \"detail\": \"签名错误\",\n" + | |||
| " \"reason\": \"参数签名结果不正确\",\n" + | |||
| " \"resolution\": \"请检查签名参数和方法是否都符合签名算法要求\"\n" + | |||
| " },\n" + | |||
| " \"XML_FORMAT_ERROR\": {\n" + | |||
| " \"detail\": \"XML格式错误\",\n" + | |||
| " \"reason\": \"XML格式错误\",\n" + | |||
| " \"resolution\": \"请检查XML参数格式是否正确\"\n" + | |||
| " },\n" + | |||
| " \"FREQUENCY_LIMITED\": {\n" + | |||
| " \"detail\": \"频率限制\",\n" + | |||
| " \"reason\": \"2个月之前的订单申请退款有频率限制\",\n" + | |||
| " \"resolution\": \"该笔退款未受理,请降低频率后重试\"\n" + | |||
| " }\n" + | |||
| "}"); | |||
| @Override | |||
| public ResultData createRefundOrder(WxAppinfo appInfo, WxRefundOrder record, EnumPayWay payWay) { | |||
| // check 是否有退款订单 | |||
| List<WxRefundOrder> list = wxRefundOrderMapper.findList(record); | |||
| if (list.size() > 0) { | |||
| throw new MallinkException(ErrorCode.REFUND_ORDER_EXIST); | |||
| } | |||
| // check 支付 订单 | |||
| WxPayOrder payOrder = null; | |||
| try { | |||
| WxPayOrder payOrderQ = new WxPayOrder(); | |||
| payOrderQ.setOrderId(record.getOrderId()); | |||
| payOrderQ.setId(Long.valueOf(record.getPayOrderNo())); | |||
| payOrderQ.setPayOrderNo(record.getPayOrderNo()); | |||
| payOrderQ.setPayOrderStatus(EnumPayStatus.PAY_WAY_SUCCESS.getCode()); | |||
| payOrder = wxPayOrderMapper.selectOne(payOrderQ); | |||
| } catch (Exception e) { | |||
| throw new MallinkException(ErrorCode.DB_FAIL); | |||
| } | |||
| if (payOrder == null) { | |||
| throw new MallinkException(ErrorCode.REFUND_PAY_ORDER_IS_NOT_EXIST); | |||
| } | |||
| if (payOrder.getPayAmount() <= 0) { | |||
| throw new MallinkException(ErrorCode.REFUND_PAY_ORDER_IS_NOT_EXIST); | |||
| } | |||
| // TODO check 可退券???? | |||
| // 创建退款订单 | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| Long id = idWorker.nextId(); | |||
| Date currentDate = new Date(); | |||
| try { | |||
| record.setId(id); | |||
| record.setTenantId(appInfo.getTenantId()); | |||
| record.setCreateTime(currentDate); | |||
| record.setUpdateTime(currentDate); | |||
| record.setTransactionId(payOrder.getTransactionId()); | |||
| record.setCUserId(payOrder.getCUserId()); | |||
| record.setTotalFee(payOrder.getPayAmount()); | |||
| record.setRefundFee(payOrder.getPayAmount()); | |||
| record.setRefundTimeStart((int)(currentDate.getTime()/1000)); | |||
| record.setRefundOrderStatus(EnumRefundStatus.REFUND_WAIT.getCode()); | |||
| int sqlRow = wxRefundOrderMapper.insertSelective(record); | |||
| if(sqlRow != 1) { | |||
| throw new MallinkException(ErrorCode.DB_FAIL); | |||
| } | |||
| } catch (Exception e) { | |||
| throw new MallinkException(ErrorCode.DB_FAIL); | |||
| } | |||
| WxPayAccount payAccount = wxPayAccountMapper.selectByPrimaryKey(appInfo.getPayId()); | |||
| // 退款申请 | |||
| try { | |||
| String noncestr = Utility.generate32UUID(); | |||
| WxRefundOrderP wxRefundOrderP = new WxRefundOrderP(); | |||
| wxRefundOrderP.setAppid(appInfo.getAppId()); | |||
| wxRefundOrderP.setMch_id(payAccount.getMchId()); | |||
| wxRefundOrderP.setNonce_str(noncestr); | |||
| wxRefundOrderP.setTransaction_id(record.getTransactionId()); | |||
| wxRefundOrderP.setOut_trade_no(record.getPayOrderNo()); | |||
| wxRefundOrderP.setTotal_fee(record.getTotalFee()); | |||
| wxRefundOrderP.setRefund_fee(record.getRefundFee()); | |||
| wxRefundOrderP.setSign(WxPayment.createSign(BeanUtils.toStringMap(wxRefundOrderP), payAccount.getApiKey())); | |||
| String response = WxPay.orderRefund(BeanUtils.toStringMap(wxRefundOrderP), payAccount.getCertPath(), payAccount.getApiKey()); | |||
| logger.info("微信退款订单:" + wxRefundOrderP.toString() + ", response: " + response.toString()); | |||
| 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"); | |||
| record.setRefundId(refund_id); | |||
| record.setRefundOrderStatus(EnumRefundStatus.REFUND_REQ_SUCCESS.getCode()); | |||
| wxRefundOrderMapper.updateByPrimaryKey(record); | |||
| return new ResultData(200, "退款订单申请成功", returnMap); | |||
| } else { | |||
| String refund_id = returnMap.get("refund_id"); | |||
| record.setRefundId(refund_id); | |||
| 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) { | |||
| throw new MallinkException(ErrorCode.REFUND_ORDER_ERROR); | |||
| } | |||
| } | |||
| // TODO | |||
| // 微信退款查询 | |||
| @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(200, "退款", returnMap); | |||
| } else { | |||
| wxRefundOrderMapper.updateByPrimaryKey(record); | |||
| JSONObject errObj = errorRefundReqMap.getJSONObject(result_no); | |||
| return new ResultData(ErrorCode.REFUND_ORDER_ERROR.getCode(), errObj.toJSONString(), returnMap); | |||
| } | |||
| } | |||
| /** | |||
| * 微信退款结果通知 | |||
| * @param paramMap 异步通知参数 | |||
| * @param payWay 支付方式 | |||
| * @return | |||
| */ | |||
| @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()); | |||
| Map<String, String> resultMap = new LinkedHashMap<>(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "订单状态码非SUCCESS"); | |||
| return XmlUtil.parseDto2Xml(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()); | |||
| Map<String, String> resultMap = new LinkedHashMap<>(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "订单不存在"); | |||
| return XmlUtil.parseDto2Xml(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()); | |||
| Map<String, String> resultMap = new LinkedHashMap<>(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "订单总金额不一致"); | |||
| return XmlUtil.parseDto2Xml(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()); | |||
| Map<String, String> resultMap = new LinkedHashMap<>(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "退款订单不存在"); | |||
| return XmlUtil.parseDto2Xml(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()); | |||
| Map<String, String> resultMap = new LinkedHashMap<>(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "订单总金额不一致"); | |||
| return XmlUtil.parseDto2Xml(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()); | |||
| Map<String, String> resultMap = new LinkedHashMap<>(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "退款总金额不一致"); | |||
| return XmlUtil.parseDto2Xml(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()); | |||
| Map<String, String> resultMap = new LinkedHashMap<>(); | |||
| resultMap.put("return_code", "SUCCESS"); | |||
| resultMap.put("return_msg", "OK"); | |||
| return XmlUtil.parseDto2Xml(resultMap, ""); | |||
| } | |||
| } catch (RuntimeException e) { | |||
| logger.warn("notify order, alipay checksign error, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString() + ", e:" + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR); | |||
| } | |||
| return ""; | |||
| } | |||
| @Override | |||
| public void callback(Map<String, String> paramMap, EnumPayWay payWay) { | |||
| } | |||
| @Override | |||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||
| public void handleRefundSuccess(WxRefundOrder refundOrder, String transactionId, String refundId) { | |||
| EnumRefundStatus refundStatus = EnumRefundStatus.getEnum(refundOrder.getRefundOrderStatus()); | |||
| // 判断退款状态 | |||
| if (refundStatus != EnumRefundStatus.REFUND_REQ_SUCCESS) { | |||
| logger.error("refund success handle, refundOrder " + refundOrder.getRefundId() + | |||
| "is paid success , orderId : " + refundOrder.getOrderId()); | |||
| return; | |||
| } | |||
| /* | |||
| WxOrder order = wxRefundOrderMapper.selectByPrimaryKey(record.getOrderId()); | |||
| if (order == null) { | |||
| logger.error("pay success handle, order " + record.getOrderId() +" not found , payOrderGid : " + record.getPayOrderNo()); | |||
| throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND); | |||
| } | |||
| Date currentDate = new Date(); | |||
| // 修改支付订单状态 | |||
| try { | |||
| WxPayOrder updatePayOrder = new WxPayOrder(); | |||
| updatePayOrder.setId(record.getId()); | |||
| updatePayOrder.setOrderId(record.getOrderId()); | |||
| updatePayOrder.setUpdateTime(currentDate); | |||
| updatePayOrder.setPayOrderStatus(EnumPayStatus.PAY_WAY_SUCCESS.getCode()); | |||
| updatePayOrder.setTransactionId(transactionId); | |||
| wxPayOrderMapper.updateByPrimaryKeySelective(updatePayOrder); | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| throw new MallinkException(ErrorCode.DB_FAIL); | |||
| } | |||
| // 修改订单状态 | |||
| try { | |||
| wxOrderService.updateOrderStatus(order.getId(), EnumOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS); | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| throw new MallinkException(ErrorCode.DB_FAIL); | |||
| } | |||
| */ | |||
| /* | |||
| Map<String, String> msgMap = new HashMap<>(); | |||
| try { | |||
| msgMap.put("name", String.valueOf(order.getCouponId())); | |||
| msgMap.put("orderNo", String.valueOf(order.getId())); | |||
| msgMap.put("createTime", Utility.getDataFormatString3(order.getCreateDate())); | |||
| msgMap.put("standingTime", order.getCreateDate() + "-" + currentDate ); | |||
| // 短信 通知 商户 | |||
| //smsSenderHandler.sendSms("SMS_18195394", order.getMobile(), msgMap); | |||
| } catch (Exception e) { | |||
| logger.error("pay success handle, sms send exception, payOrderi: " + updatePayOrder+ ", msgMap: " + msgMap.toString() + ", e: " + e.getMessage()); | |||
| } | |||
| */ | |||
| } | |||
| @Override | |||
| public PageInfo<WxRefundOrder> listAsPage(WxRefundOrder record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxRefundOrderMapper.findList(record)); | |||
| } | |||
| @Override | |||
| public WxRefundOrder getById(Long id) { | |||
| return wxRefundOrderMapper.selectByPrimaryKey(id); | |||
| } | |||
| @Override | |||
| public void saveOrUpdate(WxRefundOrder record) { | |||
| if (record.getId() == null) { | |||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| record.setId(idWorker.nextId()); | |||
| wxRefundOrderMapper.insertSelective(record); | |||
| } else { | |||
| wxRefundOrderMapper.updateByPrimaryKeySelective(record); | |||
| } | |||
| } | |||
| @Override | |||
| public void deleteById(Long id) { | |||
| wxRefundOrderMapper.deleteByPrimaryKey(id); | |||
| } | |||
| } | |||
| @@ -30,15 +30,14 @@ public class WxShopServiceImpl implements WxShopService { | |||
| @Override | |||
| public void saveOrUpdate(WxShop record) { | |||
| List<WxShop> list = wxShopMapper.findList(record); | |||
| if (record.getId() == null) { | |||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| record.setId(idWorker.nextId()); | |||
| record.setStatus(0); | |||
| record.setUpdateDate(new Date()); | |||
| record.setCreateDate(new Date()); | |||
| Date date = new Date(); | |||
| record.setUpdateDate(date); | |||
| record.setCreateDate(date); | |||
| wxShopMapper.insertSelective(record); | |||
| } else { | |||
| record.setUpdateDate(new Date()); | |||
| @@ -0,0 +1,22 @@ | |||
| package com.simple.utils; | |||
| import java.util.Comparator; | |||
| import java.util.Map; | |||
| import java.util.TreeMap; | |||
| public class MapUtil { | |||
| /** | |||
| * 获取带排序的Map | |||
| * @return | |||
| */ | |||
| public static Map<String, String> getOrderMap() { | |||
| Map<String, String> paramMap = new TreeMap<String, String>( | |||
| new Comparator<String>() { | |||
| public int compare(String obj1, String obj2) { | |||
| // 降序排序 | |||
| return obj1.compareTo(obj2); | |||
| } | |||
| }); | |||
| return paramMap; | |||
| } | |||
| } | |||
| @@ -30,4 +30,9 @@ public class RandomUtils { | |||
| return str.toString(); | |||
| } | |||
| public static void main(String[] args) { | |||
| System.out.println(getStr(32)); | |||
| } | |||
| } | |||
| @@ -60,21 +60,6 @@ public class TJDCarUtil { | |||
| */ | |||
| } | |||
| /** | |||
| * 获取带排序的Map | |||
| * @return | |||
| */ | |||
| public static Map<String, String> getOrderMap() { | |||
| Map<String, String> paramMap = new TreeMap<String, String>( | |||
| new Comparator<String>() { | |||
| public int compare(String obj1, String obj2) { | |||
| // 降序排序 | |||
| return obj1.compareTo(obj2); | |||
| } | |||
| }); | |||
| return paramMap; | |||
| } | |||
| /** | |||
| * md5算法 | |||
| * @param data | |||
| @@ -150,7 +135,7 @@ public class TJDCarUtil { | |||
| String carNum, String carNumColor, String phone, String outCarId) { | |||
| String service = "parkhub.car.register"; | |||
| Map<String, String> paramMap = getOrderMap(); | |||
| Map<String, String> paramMap = MapUtil.getOrderMap(); | |||
| paramMap.put("carNum", carNum); | |||
| paramMap.put("carNumColor", carNumColor); | |||
| if (phone != null) { | |||
| @@ -200,7 +185,7 @@ public class TJDCarUtil { | |||
| String carId) { | |||
| String service = "parkhub.car.writeOff"; | |||
| Map<String, String> paramMap = getOrderMap(); | |||
| Map<String, String> paramMap = MapUtil.getOrderMap(); | |||
| paramMap.put("carId", carId); | |||
| paramMap.put("charset", "utf-8"); | |||
| paramMap.put("partner", partner); | |||
| @@ -243,7 +228,7 @@ public class TJDCarUtil { | |||
| String freeMins = "0"; | |||
| Map<String, String> paramMap = getOrderMap(); | |||
| Map<String, String> paramMap = MapUtil.getOrderMap(); | |||
| paramMap.put("carNum", carNum); | |||
| //paramMap.put("carNumColor", ""); | |||
| //paramMap.put("pmParkId", ""); | |||
| @@ -311,7 +296,7 @@ public class TJDCarUtil { | |||
| // 为指定订单抵扣停车费,如果此时车辆已经出场,返回isSuccess错误码为3, | |||
| // 停简单系统不再接收此笔抵扣信息,对方系统需要给用户发起退款(后续业务中无结算) | |||
| String service = "parkhub.order.deductionNotSettle"; | |||
| Map<String, String> paramMap = getOrderMap(); | |||
| Map<String, String> paramMap = MapUtil.getOrderMap(); | |||
| paramMap.put("tradeId", tradeId); | |||
| paramMap.put("deductionAmount", deductionAmount); | |||
| paramMap.put("outTradeNo", outTradeNo); | |||
| @@ -360,7 +345,7 @@ public class TJDCarUtil { | |||
| String tradeId, String outTicketNo, String accountId, String prePayType, String minutes, String memo) throws Exception { | |||
| String service = "parkhub.ticket.bindTime"; | |||
| Map<String, String> paramMap = getOrderMap(); | |||
| Map<String, String> paramMap = MapUtil.getOrderMap(); | |||
| paramMap.put("tradeId", tradeId); | |||
| paramMap.put("outTicketNo", outTicketNo); | |||
| paramMap.put("accountId", accountId); | |||
| @@ -414,7 +399,7 @@ public class TJDCarUtil { | |||
| String startDt, String EndDt, String expireDt, String memo) throws Exception { | |||
| String service = "parkhub.ticket.bindPeriod"; | |||
| Map<String, String> paramMap = getOrderMap(); | |||
| Map<String, String> paramMap = MapUtil.getOrderMap(); | |||
| paramMap.put("tradeId", tradeId); | |||
| paramMap.put("outTicketNo", outTicketNo); | |||
| paramMap.put("accountId", accountId); | |||
| @@ -463,7 +448,7 @@ public class TJDCarUtil { | |||
| String tradeId, String ticketid) throws Exception { | |||
| String service = "parkhub.ticket.unbind"; | |||
| Map<String, String> paramMap = getOrderMap(); | |||
| Map<String, String> paramMap = MapUtil.getOrderMap(); | |||
| paramMap.put("tradeId", tradeId); | |||
| paramMap.put("ticketid", ticketid); | |||
| paramMap.put("charset", "utf-8"); | |||
| @@ -10,15 +10,14 @@ | |||
| <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="mch_id" jdbcType="VARCHAR" property="mchId" /> | |||
| <result column="notify_url" jdbcType="VARCHAR" property="notifyUrl" /> | |||
| <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" /> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`app_id`,`name`,`secret`,`token`,`aes_key`,`msg_data_format`,`mch_id`,`notify_url`,`access_token`,`last_token_time`,`expires_in` | |||
| `id`,`tenant_id`,`app_id`,`name`,`secret`,`token`,`aes_key`,`msg_data_format`,`access_token`,`last_token_time`,`expires_in`,`pay_id` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -61,15 +60,6 @@ | |||
| <if test=" null != msgDataFormat "> | |||
| and `msg_data_format` like concat('%', #{msgDataFormat},'%') | |||
| </if> | |||
| <if test=" null != mchId "> | |||
| and `mch_id` like concat('%', #{mchId},'%') | |||
| </if> | |||
| <if test=" null != notifyUrl "> | |||
| and `notify_url` like concat('%', #{notifyUrl},'%') | |||
| </if> | |||
| @@ -86,6 +76,11 @@ | |||
| <if test=" null != expiresIn "> | |||
| and `expires_in` = #{expiresIn} | |||
| </if> | |||
| <if test=" null != payId "> | |||
| and `pay_id` = #{payId} | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| @@ -2,7 +2,7 @@ | |||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||
| <mapper namespace="com.simple.mapper.WxMallMapper"> | |||
| <resultMap id="BaseResultMap" type="com.simple.domain.po.WxMall"> | |||
| <id column="mall_id" jdbcType="BIGINT" property="mallId" /> | |||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||
| <result column="name" jdbcType="VARCHAR" property="name" /> | |||
| <result column="group" jdbcType="VARCHAR" property="group" /> | |||
| @@ -15,17 +15,18 @@ | |||
| <result column="operating_area" jdbcType="DECIMAL" property="operatingArea" /> | |||
| <result column="park_area" jdbcType="DECIMAL" property="parkArea" /> | |||
| <result column="park_place_number" jdbcType="INTEGER" property="parkPlaceNumber" /> | |||
| <result column="pay_id" jdbcType="BIGINT" property="payId" /> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `mall_id`,`tenant_id`,`name`,`group`,`country`,`province`,`city`,`addr`,`wiwide_id`,`total_area`,`operating_area`,`park_area`,`park_place_number` | |||
| `id`,`tenant_id`,`name`,`group`,`country`,`province`,`city`,`addr`,`wiwide_id`,`total_area`,`operating_area`,`park_area`,`park_place_number`,`pay_id` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| where 1 = 1 | |||
| <if test=" null != mallId "> | |||
| and `mall_id` = #{mallId} | |||
| <if test=" null != id "> | |||
| and `id` = #{id} | |||
| </if> | |||
| @@ -87,9 +88,14 @@ | |||
| <if test=" null != parkPlaceNumber "> | |||
| and `park_place_number` = #{parkPlaceNumber} | |||
| </if> | |||
| <if test=" null != payId "> | |||
| and `pay_id` = #{payId} | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and mall_id in | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| #{idItem} | |||
| </foreach> | |||
| @@ -9,15 +9,17 @@ | |||
| <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="wxchat_account" jdbcType="VARCHAR" property="wxchatAccount" /> | |||
| <result column="pay_id" jdbcType="BIGINT" property="payId" /> | |||
| <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" /> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`img_url`,`name`,`link_phone`,`bank_card`,`bank_name`,`wxchat_account`,`create_date`,`update_date`,`car_vendor_type`,`car_params` | |||
| `id`,`tenant_id`,`img_url`,`name`,`link_phone`,`bank_card`,`bank_name`,`pay_id`,`create_date`,`update_date`,`car_vendor_type`,`car_params`,`status` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -58,8 +60,8 @@ | |||
| </if> | |||
| <if test=" null != wxchatAccount "> | |||
| and `wxchat_account` like concat('%', #{wxchatAccount},'%') | |||
| <if test=" null != payId "> | |||
| and `pay_id` = #{payId} | |||
| </if> | |||
| @@ -81,7 +83,13 @@ | |||
| <if test=" null != carParams "> | |||
| and `car_params` like concat('%', #{carParams},'%') | |||
| </if> | |||
| </if> | |||
| <if test=" null != status "> | |||
| and `status` = #{status} | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| @@ -13,10 +13,11 @@ | |||
| <result column="order_status" jdbcType="INTEGER" property="orderStatus" /> | |||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | |||
| <result column="detail" jdbcType="VARCHAR" property="detail" /> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`order_number`,`tenant_id`,`c_user_id`,`b_user_id`,`payment_type`,`payment`,`payment_time`,`order_status`,`create_date`,`update_date` | |||
| `id`,`order_number`,`tenant_id`,`c_user_id`,`b_user_id`,`payment_type`,`payment`,`payment_time`,`order_status`,`create_date`,`update_date`,`detail` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -75,6 +76,11 @@ | |||
| <if test=" null != updateDate "> | |||
| and `update_date` = #{updateDate} | |||
| </if> | |||
| <if test=" null != detail "> | |||
| and `detail` like concat('%', #{detail},'%') | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| @@ -0,0 +1,62 @@ | |||
| <?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.WxPayAccountMapper"> | |||
| <resultMap id="BaseResultMap" type="com.simple.domain.po.WxPayAccount"> | |||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||
| <result column="mch_id" jdbcType="VARCHAR" property="mchId" /> | |||
| <result column="api_key" jdbcType="VARCHAR" property="apiKey" /> | |||
| <result column="notify_url" jdbcType="VARCHAR" property="notifyUrl" /> | |||
| <result column="cert_path" jdbcType="VARCHAR" property="certPath" /> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`mch_id`,`api_key`,`notify_url`,`cert_path` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| where 1 = 1 | |||
| <if test=" null != id "> | |||
| and `id` = #{id} | |||
| </if> | |||
| <if test=" null != mchId "> | |||
| and `mch_id` like concat('%', #{mchId},'%') | |||
| </if> | |||
| <if test=" null != apiKey "> | |||
| and `api_key` like concat('%', #{apiKey},'%') | |||
| </if> | |||
| <if test=" null != notifyUrl "> | |||
| and `notify_url` like concat('%', #{notifyUrl},'%') | |||
| </if> | |||
| <if test=" null != certPath "> | |||
| and `cert_path` like concat('%', #{certPath},'%') | |||
| </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.WxPayAccount" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns" /> from wx_pay_account | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| </mapper> | |||
| @@ -0,0 +1,128 @@ | |||
| <?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.WxRefundOrderMapper"> | |||
| <resultMap id="BaseResultMap" type="com.simple.domain.po.WxRefundOrder"> | |||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||
| <result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> | |||
| <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" /> | |||
| <result column="transaction_id" jdbcType="VARCHAR" property="transactionId" /> | |||
| <result column="order_id" jdbcType="BIGINT" property="orderId" /> | |||
| <result column="pay_order_no" jdbcType="VARCHAR" property="payOrderNo" /> | |||
| <result column="c_user_id" jdbcType="BIGINT" property="cUserId" /> | |||
| <result column="total_fee" jdbcType="INTEGER" property="totalFee" /> | |||
| <result column="refund_fee" jdbcType="INTEGER" property="refundFee" /> | |||
| <result column="refund_time_start" jdbcType="INTEGER" property="refundTimeStart" /> | |||
| <result column="refund_time_end" jdbcType="INTEGER" property="refundTimeEnd" /> | |||
| <result column="refund_vendor" jdbcType="INTEGER" property="refundVendor" /> | |||
| <result column="refund_order_status" jdbcType="INTEGER" property="refundOrderStatus" /> | |||
| <result column="refund_id" jdbcType="VARCHAR" property="refundId" /> | |||
| <result column="fail_reason" jdbcType="VARCHAR" property="failReason" /> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`create_time`,`update_time`,`transaction_id`,`order_id`,`pay_order_no`,`c_user_id`,`total_fee`,`refund_fee`,`refund_time_start`,`refund_time_end`,`refund_vendor`,`refund_order_status`,`refund_id`,`fail_reason` | |||
| </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> | |||
| <if test=" null != createTime "> | |||
| and `create_time` = #{createTime} | |||
| </if> | |||
| <if test=" null != updateTime "> | |||
| and `update_time` = #{updateTime} | |||
| </if> | |||
| <if test=" null != transactionId "> | |||
| and `transaction_id` like concat('%', #{transactionId},'%') | |||
| </if> | |||
| <if test=" null != orderId "> | |||
| and `order_id` = #{orderId} | |||
| </if> | |||
| <if test=" null != payOrderNo "> | |||
| and `pay_order_no` like concat('%', #{payOrderNo},'%') | |||
| </if> | |||
| <if test=" null != cUserId "> | |||
| and `c_user_id` = #{cUserId} | |||
| </if> | |||
| <if test=" null != totalFee "> | |||
| and `total_fee` = #{totalFee} | |||
| </if> | |||
| <if test=" null != refundFee "> | |||
| and `refund_fee` = #{refundFee} | |||
| </if> | |||
| <if test=" null != refundTimeStart "> | |||
| and `refund_time_start` = #{refundTimeStart} | |||
| </if> | |||
| <if test=" null != refundTimeEnd "> | |||
| and `refund_time_end` = #{refundTimeEnd} | |||
| </if> | |||
| <if test=" null != refundVendor "> | |||
| and `refund_vendor` = #{refundVendor} | |||
| </if> | |||
| <if test=" null != refundOrderStatus "> | |||
| and `refund_order_status` = #{refundOrderStatus} | |||
| </if> | |||
| <if test=" null != refundId "> | |||
| and `refund_id` like concat('%', #{refundId},'%') | |||
| </if> | |||
| <if test=" null != failReason "> | |||
| and `fail_reason` like concat('%', #{failReason},'%') | |||
| </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.WxRefundOrder" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns" /> from wx_refund_order | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| </mapper> | |||