| @@ -15,6 +15,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2; | |||||
| @MapperScan(basePackages = {"com.simple.mapper"}) | @MapperScan(basePackages = {"com.simple.mapper"}) | ||||
| @EnableSwagger2 | @EnableSwagger2 | ||||
| @EnableEncryptableProperties | @EnableEncryptableProperties | ||||
| public class UserApplication { | public class UserApplication { | ||||
| public static void main(String[] args) { | public static void main(String[] args) { | ||||
| @@ -121,6 +121,7 @@ public class ShiroConfig { | |||||
| filterChainDefinitionMap.put("/wxMallApply/add","anon"); | filterChainDefinitionMap.put("/wxMallApply/add","anon"); | ||||
| filterChainDefinitionMap.put("/wxMallApply/sendvalidationcode","anon"); | filterChainDefinitionMap.put("/wxMallApply/sendvalidationcode","anon"); | ||||
| filterChainDefinitionMap.put("/captcha.jpg", "anon"); | filterChainDefinitionMap.put("/captcha.jpg", "anon"); | ||||
| filterChainDefinitionMap.put("/version", "anon"); | |||||
| // filterChainDefinitionMap.put("/role/**", "corsFilter,token"); | // filterChainDefinitionMap.put("/role/**", "corsFilter,token"); | ||||
| filterChainDefinitionMap.put("/**", "corsFilter,token,authc"); | filterChainDefinitionMap.put("/**", "corsFilter,token,authc"); | ||||
| // filterChainDefinitionMap.put("/**", "anon"); | // filterChainDefinitionMap.put("/**", "anon"); | ||||
| @@ -5,6 +5,7 @@ import com.github.pagehelper.PageInfo; | |||||
| import com.simple.common.Result; | import com.simple.common.Result; | ||||
| import com.simple.common.ResultData; | import com.simple.common.ResultData; | ||||
| import com.simple.domain.po.CouponInject; | import com.simple.domain.po.CouponInject; | ||||
| import com.simple.enums.EnumCouponInjectSendType; | |||||
| import com.simple.service.CouponInjectService; | import com.simple.service.CouponInjectService; | ||||
| import com.simple.service.WxCUserTagsService; | import com.simple.service.WxCUserTagsService; | ||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| @@ -51,7 +52,7 @@ public class CouponInjectController extends BaseController { | |||||
| couponInject.setTenantId(getUser().getTenantId()); | couponInject.setTenantId(getUser().getTenantId()); | ||||
| couponInject.setMUserId(getUser().getId()); | couponInject.setMUserId(getUser().getId()); | ||||
| if (couponInject.getSendType() == 0) { | |||||
| if (couponInject.getSendType() == EnumCouponInjectSendType.IMMEDIATE.getCode()) { | |||||
| couponInject.setSendTime(new Date()); | couponInject.setSendTime(new Date()); | ||||
| } | } | ||||
| //Assert.notNull(couponInject.getName(), "角色名不能为空"); | //Assert.notNull(couponInject.getName(), "角色名不能为空"); | ||||
| @@ -21,6 +21,7 @@ import org.apache.shiro.subject.Subject; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.beans.factory.annotation.Value; | |||||
| import org.springframework.util.StringUtils; | import org.springframework.util.StringUtils; | ||||
| import org.springframework.web.bind.annotation.*; | import org.springframework.web.bind.annotation.*; | ||||
| @@ -37,6 +38,8 @@ import java.io.IOException; | |||||
| public class HomeController { | public class HomeController { | ||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
| @Value("${version}") | |||||
| private String version; | |||||
| @Autowired | @Autowired | ||||
| private Producer producer; | private Producer producer; | ||||
| @@ -47,7 +50,7 @@ public class HomeController { | |||||
| @Autowired | @Autowired | ||||
| private MallRolePermissionService mallRolePermissionService; | private MallRolePermissionService mallRolePermissionService; | ||||
| @RequestMapping("/captcha.jpg") | |||||
| @GetMapping("/captcha.jpg") | |||||
| public void captcha(HttpServletResponse response)throws ServletException, IOException { | public void captcha(HttpServletResponse response)throws ServletException, IOException { | ||||
| response.setHeader("Cache-Control", "no-store, no-cache"); | response.setHeader("Cache-Control", "no-store, no-cache"); | ||||
| response.setContentType("image/jpeg"); | response.setContentType("image/jpeg"); | ||||
| @@ -66,12 +69,10 @@ public class HomeController { | |||||
| @ApiOperation("登录") | @ApiOperation("登录") | ||||
| @PostMapping("/doLogin") | @PostMapping("/doLogin") | ||||
| public ResultData login(@RequestBody MallUserInfo user, String captcha) { | |||||
| if (captcha != null) { | |||||
| String kaptcha = ShiroUtils.getKaptcha(Constants.KAPTCHA_SESSION_KEY); | |||||
| if(!captcha.equalsIgnoreCase(kaptcha)){ | |||||
| return new ResultData(ErrorCode.KAPCHA_NOT_EQUAL); | |||||
| } | |||||
| public ResultData login(@RequestBody MallUserInfo user) { | |||||
| String kaptcha = ShiroUtils.getKaptcha(Constants.KAPTCHA_SESSION_KEY); | |||||
| if(!user.getCaptcha().equalsIgnoreCase(kaptcha)){ | |||||
| return new ResultData(ErrorCode.KAPCHA_NOT_EQUAL); | |||||
| } | } | ||||
| ResultData data = new ResultData(); | ResultData data = new ResultData(); | ||||
| @@ -125,4 +126,10 @@ public class HomeController { | |||||
| SecurityUtils.getSubject().logout(); | SecurityUtils.getSubject().logout(); | ||||
| return data; | return data; | ||||
| } | } | ||||
| @ApiOperation("获取后端版本号") | |||||
| @GetMapping("/version") | |||||
| public ResultData version() { | |||||
| return new ResultData(version); | |||||
| } | |||||
| } | } | ||||
| @@ -1,6 +1,7 @@ | |||||
| package com.simple.controller; | package com.simple.controller; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.simple.common.ErrorCode; | |||||
| import com.simple.common.ResultData; | import com.simple.common.ResultData; | ||||
| import com.simple.domain.po.*; | import com.simple.domain.po.*; | ||||
| import com.simple.service.*; | import com.simple.service.*; | ||||
| @@ -78,8 +79,13 @@ public class MallUserInfoController extends BaseController { | |||||
| @ApiOperation(value = "创建用户接口", response = String.class) | @ApiOperation(value = "创建用户接口", response = String.class) | ||||
| @PostMapping("add") | @PostMapping("add") | ||||
| public ResultData createUser(@RequestBody MallUserInfo userInfo) { | public ResultData createUser(@RequestBody MallUserInfo userInfo) { | ||||
| Assert.notNull(userInfo.getUsername(), "用户名不能为空"); | |||||
| Assert.isTrue(checkUnique(userInfo.getUsername(), 0), "重复的用户名"); | |||||
| if(checkUniqueName(userInfo.getUsername(), null)){ | |||||
| return new ResultData(ErrorCode.USER_NAME_IS_FOUND,"用户名已存在"); | |||||
| } | |||||
| if(checkUniquePhone(userInfo.getPhone(), null)){ | |||||
| return new ResultData(ErrorCode.USER_PHONE_IS_FOUND,"手机号已存在"); | |||||
| } | |||||
| Assert.notNull(userInfo.getPassword(), "密码不能为空"); | Assert.notNull(userInfo.getPassword(), "密码不能为空"); | ||||
| PasswordHelper passwordHelper = new PasswordHelper(); | PasswordHelper passwordHelper = new PasswordHelper(); | ||||
| passwordHelper.encryptPassword(userInfo); | passwordHelper.encryptPassword(userInfo); | ||||
| @@ -97,8 +103,13 @@ public class MallUserInfoController extends BaseController { | |||||
| @ApiOperation(value = "修改用户接口", response = String.class) | @ApiOperation(value = "修改用户接口", response = String.class) | ||||
| @PostMapping("update") | @PostMapping("update") | ||||
| public ResultData updateUser(@RequestBody MallUserInfo userInfo) { | public ResultData updateUser(@RequestBody MallUserInfo userInfo) { | ||||
| Assert.notNull(userInfo.getUsername(), "用户名不能为空"); | |||||
| Assert.isTrue(checkUnique(userInfo.getUsername(), 1), "重复的用户名"); | |||||
| //Assert.notNull(userInfo.getUsername(), "用户名不能为空"); | |||||
| if(checkUniqueName(userInfo.getUsername(), userInfo.getId())){ | |||||
| return new ResultData(ErrorCode.USER_NAME_IS_FOUND,"用户名已存在"); | |||||
| } | |||||
| if(checkUniquePhone(userInfo.getPhone(), userInfo.getId())){ | |||||
| return new ResultData(ErrorCode.USER_PHONE_IS_FOUND,"手机号已存在"); | |||||
| } | |||||
| // Assert.notNull(userInfo.getPassword(), "密码不能为空"); | // Assert.notNull(userInfo.getPassword(), "密码不能为空"); | ||||
| // PasswordHelper passwordHelper = new PasswordHelper(); | // PasswordHelper passwordHelper = new PasswordHelper(); | ||||
| // passwordHelper.encryptPassword(userInfo); | // passwordHelper.encryptPassword(userInfo); | ||||
| @@ -155,18 +166,12 @@ public class MallUserInfoController extends BaseController { | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| private boolean checkUnique(String username, Integer type) { | |||||
| if (type == 0) { | |||||
| if (userInfoService.cntByUserName(username) > 0) { | |||||
| return false; | |||||
| } | |||||
| } | |||||
| if (type == 1) { | |||||
| if (userInfoService.cntByUserName(username) > 1) { | |||||
| return false; | |||||
| } | |||||
| } | |||||
| return true; | |||||
| private boolean checkUniqueName(String username, Long id) { | |||||
| return userInfoService.cntByUserName(username,id); | |||||
| } | |||||
| private boolean checkUniquePhone(String phone, Long id) { | |||||
| return userInfoService.cntByUserPhone(phone,id); | |||||
| } | } | ||||
| @@ -8,7 +8,7 @@ import com.simple.domain.po.WxCarCmdLog; | |||||
| import com.simple.domain.po.WxPark; | import com.simple.domain.po.WxPark; | ||||
| import com.simple.enums.EnumCarCmd; | import com.simple.enums.EnumCarCmd; | ||||
| import com.simple.enums.EnumCarVendor; | import com.simple.enums.EnumCarVendor; | ||||
| import com.simple.enums.EnumCouponSendType; | |||||
| import com.simple.enums.EnumCouponSendSendType; | |||||
| import com.simple.enums.EnumETCPCode; | import com.simple.enums.EnumETCPCode; | ||||
| import com.simple.service.*; | import com.simple.service.*; | ||||
| import com.simple.utils.ETCPUtil; | import com.simple.utils.ETCPUtil; | ||||
| @@ -109,7 +109,7 @@ public class WxCarCallBackController extends BaseController { | |||||
| // TODO 可能多用户关联同一张车牌 | // TODO 可能多用户关联同一张车牌 | ||||
| List<WxCUserCar> userCarList = wxCUserCarService.getList(userCarQ); | List<WxCUserCar> userCarList = wxCUserCarService.getList(userCarQ); | ||||
| for (WxCUserCar userCar : userCarList) { | for (WxCUserCar userCar : userCarList) { | ||||
| wxCouponSendService.sendCouponToUser(tenantId, userCar.getCUserId(), EnumCouponSendType.CAR_STOP); | |||||
| wxCouponSendService.sendCouponToUser(tenantId, userCar.getCUserId(), EnumCouponSendSendType.CAR_STOP); | |||||
| } | } | ||||
| } | } | ||||
| @@ -1,10 +1,13 @@ | |||||
| package com.simple.controller; | package com.simple.controller; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.simple.common.ErrorCode; | |||||
| import com.simple.common.Result; | import com.simple.common.Result; | ||||
| import com.simple.common.ResultData; | import com.simple.common.ResultData; | ||||
| import com.simple.domain.po.WxCoupon; | import com.simple.domain.po.WxCoupon; | ||||
| import com.simple.domain.po.WxCouponSend; | import com.simple.domain.po.WxCouponSend; | ||||
| import com.simple.enums.EnumCouponSendType; | |||||
| import com.simple.enums.EnumCouponStatus; | |||||
| import com.simple.service.WxCouponSendService; | import com.simple.service.WxCouponSendService; | ||||
| import com.simple.service.WxCouponService; | import com.simple.service.WxCouponService; | ||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| @@ -43,19 +46,24 @@ public class WxCouponSendController extends BaseController { | |||||
| @PostMapping("add") | @PostMapping("add") | ||||
| public ResultData add(@RequestBody WxCouponSend wxCouponSend) { | public ResultData add(@RequestBody WxCouponSend wxCouponSend) { | ||||
| if (null == wxCouponSend) { | if (null == wxCouponSend) { | ||||
| return new ResultData(Result.ERROR, "参数不对"); | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||||
| } | } | ||||
| wxCouponSend.setTenantId(getTenantId()); | wxCouponSend.setTenantId(getTenantId()); | ||||
| wxCouponSend.setStatus(0); | wxCouponSend.setStatus(0); | ||||
| List<WxCouponSend> wxCouponSendList = wxCouponSendService.listAsPage(wxCouponSend, 1, 1).getList(); | List<WxCouponSend> wxCouponSendList = wxCouponSendService.listAsPage(wxCouponSend, 1, 1).getList(); | ||||
| if (wxCouponSendList != null && wxCouponSendList.size() > 0) { | if (wxCouponSendList != null && wxCouponSendList.size() > 0) { | ||||
| return new ResultData(Result.ERROR, "已经添加过该券"); | |||||
| return new ResultData(ErrorCode.COUPON_SEND_IS_EXISTED); | |||||
| } | } | ||||
| WxCoupon wxCoupon = wxCouponService.getById(wxCouponSend.getCouponId()); | WxCoupon wxCoupon = wxCouponService.getById(wxCouponSend.getCouponId()); | ||||
| if (wxCoupon.getStatus() != 0 || wxCoupon.getSendType() != 2) { | |||||
| return new ResultData(Result.ERROR, "该券的状态有问题"); | |||||
| if (wxCoupon.getStatus() != EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode()){ | |||||
| return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF); | |||||
| } | } | ||||
| if (wxCoupon.getSendType() != EnumCouponSendType.PASSIVE.getCode()) { | |||||
| return new ResultData(ErrorCode.COUPON_TYPE_IS_NOT_PASSIVE); | |||||
| } | |||||
| wxCouponSend.setMerchantId(wxCoupon.getMerchantId()); | wxCouponSend.setMerchantId(wxCoupon.getMerchantId()); | ||||
| wxCouponSend.setType(wxCoupon.getType()); | wxCouponSend.setType(wxCoupon.getType()); | ||||
| wxCouponSend.setTenantId(wxCoupon.getTenantId()); | wxCouponSend.setTenantId(wxCoupon.getTenantId()); | ||||
| @@ -75,14 +75,4 @@ public class WxPayOrderController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| private WxAppinfoService wxAppinfoService; | private WxAppinfoService wxAppinfoService; | ||||
| @ApiOperation("测试分账") | |||||
| @GetMapping("/sharing") | |||||
| public ResultData test() { | |||||
| //xProfitSharingOrderService.test(); | |||||
| wxPayOrderService.sendPaySuccess(); | |||||
| return new ResultData(); | |||||
| } | |||||
| } | } | ||||
| @@ -101,13 +101,17 @@ public class WxUserStructureController extends BaseController { | |||||
| WxCUserBasicInfoDto dto = new WxCUserBasicInfoDto(); | WxCUserBasicInfoDto dto = new WxCUserBasicInfoDto(); | ||||
| dto.setTenantId(getTenantId()); | dto.setTenantId(getTenantId()); | ||||
| dto.setStartTime(startTime); | dto.setStartTime(startTime); | ||||
| dto.setEndTime(endTime); | |||||
| if (endTime != null) { | if (endTime != null) { | ||||
| Calendar c = Calendar.getInstance(); | Calendar c = Calendar.getInstance(); | ||||
| c.setTime(endTime); | c.setTime(endTime); | ||||
| c.add(Calendar.DAY_OF_YEAR, 1); | c.add(Calendar.DAY_OF_YEAR, 1); | ||||
| endTime = c.getTime(); | endTime = c.getTime(); | ||||
| } | } | ||||
| long allCount = wxCUserService.findCount(dto);//总量 | |||||
| //微信用户数据 | |||||
| long wxallCount = wxCUserService.findCount(dto);//总量 | |||||
| //会员数据 | |||||
| Map<String,Object> member=getMemberData(dto); | |||||
| Calendar c = Calendar.getInstance(); | Calendar c = Calendar.getInstance(); | ||||
| c.set(Calendar.HOUR_OF_DAY, 0); | c.set(Calendar.HOUR_OF_DAY, 0); | ||||
| @@ -116,8 +120,8 @@ public class WxUserStructureController extends BaseController { | |||||
| Date today = c.getTime(); | Date today = c.getTime(); | ||||
| dto.setStartTime(today); | dto.setStartTime(today); | ||||
| dto.setEndTime(null); | dto.setEndTime(null); | ||||
| long todayCount = wxCUserService.findCount(dto);//今天新增 | |||||
| List<UserStructureVo> newCountVos = new ArrayList<>();//每日新增会员数 | |||||
| long wxtodayCount = wxCUserService.findCount(dto);//今天新增 | |||||
| List<UserStructureVo> wxnewCountVos = new ArrayList<>();//每日新增会员数 | |||||
| int j = 1; | int j = 1; | ||||
| for (int i = 29; i >= 0; i--) { | for (int i = 29; i >= 0; i--) { | ||||
| c.clear(); | c.clear(); | ||||
| @@ -132,6 +136,64 @@ public class WxUserStructureController extends BaseController { | |||||
| j++; | j++; | ||||
| vo.setName(new SimpleDateFormat("MM-dd").format(dto.getStartTime())); | vo.setName(new SimpleDateFormat("MM-dd").format(dto.getStartTime())); | ||||
| vo.setCount(count); | vo.setCount(count); | ||||
| wxnewCountVos.add(vo); | |||||
| } | |||||
| List<UserStructureVo> wxallCountVos = new ArrayList<>();//累计会员数 | |||||
| c.clear(); | |||||
| c.setTime(today); | |||||
| c.add(Calendar.DAY_OF_YEAR, -30); | |||||
| dto.setEndTime(c.getTime()); | |||||
| dto.setStartTime(null); | |||||
| long firstDay = wxCUserService.findCount(dto);//统计的第一天总数 | |||||
| int i = 0; | |||||
| long sumCount = 0; | |||||
| for (UserStructureVo v : wxnewCountVos) { | |||||
| UserStructureVo vo = new UserStructureVo(); | |||||
| sumCount += v.getCount(); | |||||
| vo.setCount(firstDay + sumCount); | |||||
| vo.setName(v.getName()); | |||||
| vo.setSortNum(i + 1); | |||||
| wxallCountVos.add(vo); | |||||
| i++; | |||||
| } | |||||
| Map<String, Object> map = new HashMap<>(); | |||||
| map.put("wxallCount", wxallCount);//累计会员总数 | |||||
| map.put("wxtodayCount", wxtodayCount);//今日新增会员数 | |||||
| map.put("wxallCountVos", wxallCountVos);//累计会员列表( 日期和数量list) | |||||
| map.put("wxnewCountVos", wxnewCountVos);//新增会员列表(日期和数量list) | |||||
| map.putAll(member); | |||||
| return new ResultData(map); | |||||
| } | |||||
| private Map<String,Object> getMemberData(WxCUserBasicInfoDto dto) { | |||||
| long allCount = wxCUserBasicInfoService.findCount(dto);//总量 | |||||
| Calendar c = Calendar.getInstance(); | |||||
| c.set(Calendar.HOUR_OF_DAY, 0); | |||||
| c.set(Calendar.MINUTE, 0); | |||||
| c.set(Calendar.SECOND, 0); | |||||
| Date today = c.getTime(); | |||||
| dto.setStartTime(today); | |||||
| dto.setEndTime(null); | |||||
| long todayCount = wxCUserBasicInfoService.findCount(dto);//今天新增 | |||||
| List<UserStructureVo> newCountVos = new ArrayList<>();//每日新增会员数 | |||||
| int j = 1; | |||||
| for (int i = 29; i >= 0; i--) { | |||||
| c.clear(); | |||||
| c.setTime(today); | |||||
| c.add(Calendar.DAY_OF_YEAR, -i); | |||||
| dto.setStartTime(c.getTime()); | |||||
| c.add(Calendar.DAY_OF_YEAR, 1); | |||||
| dto.setEndTime(c.getTime()); | |||||
| long count = wxCUserBasicInfoService.findCount(dto); | |||||
| UserStructureVo vo = new UserStructureVo(); | |||||
| vo.setSortNum(j); | |||||
| j++; | |||||
| vo.setName(new SimpleDateFormat("MM-dd").format(dto.getStartTime())); | |||||
| vo.setCount(count); | |||||
| newCountVos.add(vo); | newCountVos.add(vo); | ||||
| } | } | ||||
| List<UserStructureVo> allCountVos = new ArrayList<>();//累计会员数 | List<UserStructureVo> allCountVos = new ArrayList<>();//累计会员数 | ||||
| @@ -140,7 +202,7 @@ public class WxUserStructureController extends BaseController { | |||||
| c.add(Calendar.DAY_OF_YEAR, -30); | c.add(Calendar.DAY_OF_YEAR, -30); | ||||
| dto.setEndTime(c.getTime()); | dto.setEndTime(c.getTime()); | ||||
| dto.setStartTime(null); | dto.setStartTime(null); | ||||
| long firstDay = wxCUserService.findCount(dto);//统计的第一天总数 | |||||
| long firstDay = wxCUserBasicInfoService.findCount(dto);//统计的第一天总数 | |||||
| int i = 0; | int i = 0; | ||||
| long sumCount = 0; | long sumCount = 0; | ||||
| for (UserStructureVo v : newCountVos) { | for (UserStructureVo v : newCountVos) { | ||||
| @@ -152,12 +214,15 @@ public class WxUserStructureController extends BaseController { | |||||
| allCountVos.add(vo); | allCountVos.add(vo); | ||||
| i++; | i++; | ||||
| } | } | ||||
| Map<String, Object> map = new HashMap<>(); | Map<String, Object> map = new HashMap<>(); | ||||
| map.put("allCount", allCount);//累计会员总数 | map.put("allCount", allCount);//累计会员总数 | ||||
| map.put("todayCount", todayCount);//今日新增会员数 | map.put("todayCount", todayCount);//今日新增会员数 | ||||
| map.put("allCountVos", allCountVos);//累计会员列表( 日期和数量list) | map.put("allCountVos", allCountVos);//累计会员列表( 日期和数量list) | ||||
| map.put("newCountVos", newCountVos);//新增会员列表(日期和数量list) | map.put("newCountVos", newCountVos);//新增会员列表(日期和数量list) | ||||
| return new ResultData(map); | |||||
| return map; | |||||
| } | } | ||||
| @ApiOperation("拓客分析") | @ApiOperation("拓客分析") | ||||
| @@ -3,6 +3,7 @@ package com.simple.schedule; | |||||
| import com.simple.domain.po.WxOrder; | import com.simple.domain.po.WxOrder; | ||||
| import com.simple.enums.EnumOrderStatus; | import com.simple.enums.EnumOrderStatus; | ||||
| import com.simple.mapper.WxOrderMapper; | import com.simple.mapper.WxOrderMapper; | ||||
| import com.simple.service.WxOrderService; | |||||
| import org.apache.log4j.Logger; | import org.apache.log4j.Logger; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.scheduling.annotation.Scheduled; | import org.springframework.scheduling.annotation.Scheduled; | ||||
| @@ -25,7 +26,10 @@ public class OrderExpiringSchedule { | |||||
| @Autowired | @Autowired | ||||
| WxOrderMapper wxOrderMapper; | WxOrderMapper wxOrderMapper; | ||||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||||
| @Autowired | |||||
| WxOrderService wxOrderService; | |||||
| @Scheduled(cron = "0 */5 * * * *?") // 每5分钟检查一次 | @Scheduled(cron = "0 */5 * * * *?") // 每5分钟检查一次 | ||||
| //@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 | //@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 | ||||
| public void orderExpireSchedule() { | public void orderExpireSchedule() { | ||||
| @@ -38,13 +42,21 @@ public class OrderExpiringSchedule { | |||||
| List<WxOrder> wxOrderList = wxOrderMapper.findListOfUnpaidOrderByDate(dateMap); | List<WxOrder> wxOrderList = wxOrderMapper.findListOfUnpaidOrderByDate(dateMap); | ||||
| for(WxOrder wxOrder: wxOrderList){ | for(WxOrder wxOrder: wxOrderList){ | ||||
| wxOrder.setUpdateDate(new Date()); | |||||
| wxOrder.setOrderStatus(EnumOrderStatus.ORDER_STATUS_OVERTIME_CANCEL.getCode()); | |||||
| wxOrderMapper.updateByPrimaryKeySelective(wxOrder); | |||||
| logger.info("\nFound " + wxOrder.getId() + "\n" | |||||
| + " create at " + wxOrder.getCreateDate() +"\n" | |||||
| + " expired at " + new Date()); | |||||
| orderExpired(wxOrder); | |||||
| } | } | ||||
| } | } | ||||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||||
| public void orderExpired(WxOrder order) { | |||||
| order.setUpdateDate(new Date()); | |||||
| order.setOrderStatus(EnumOrderStatus.ORDER_STATUS_OVERTIME_CANCEL.getCode()); | |||||
| wxOrderMapper.updateByPrimaryKeySelective(order); | |||||
| // 微信 关单 | |||||
| wxOrderService.orderClose(order); | |||||
| logger.info("\nFound " + order.getId() + "\n" | |||||
| + " create at " + order.getCreateDate() +"\n" | |||||
| + " expired at " + new Date()); | |||||
| } | |||||
| } | } | ||||
| @@ -51,3 +51,4 @@ jasypt: | |||||
| encryptor: | encryptor: | ||||
| password: oRqdnDbK5pj3eMmB | password: oRqdnDbK5pj3eMmB | ||||
| version: @project.version@ | |||||
| @@ -147,6 +147,15 @@ public class WxCouponOrderController extends BaseController { | |||||
| } | } | ||||
| } | } | ||||
| // 核销发模板消息 | |||||
| if (couponOrder != null) { | |||||
| try { | |||||
| wxCouponOrderService.sendVerifyMsg(couponOrder, getUser()); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| } | |||||
| return new ResultData(couponOrder); | return new ResultData(couponOrder); | ||||
| } | } | ||||
| @@ -14,6 +14,7 @@ import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.beans.factory.annotation.Value; | |||||
| import org.springframework.web.bind.annotation.GetMapping; | import org.springframework.web.bind.annotation.GetMapping; | ||||
| import org.springframework.web.bind.annotation.RequestMapping; | import org.springframework.web.bind.annotation.RequestMapping; | ||||
| import org.springframework.web.bind.annotation.ResponseBody; | import org.springframework.web.bind.annotation.ResponseBody; | ||||
| @@ -32,6 +33,9 @@ import java.util.Map; | |||||
| public class WxMallController extends BaseController { | public class WxMallController extends BaseController { | ||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
| @Value("${version}") | |||||
| private String version; | |||||
| @Autowired | @Autowired | ||||
| private WxMallService wxMallService; | private WxMallService wxMallService; | ||||
| @@ -73,7 +77,12 @@ public class WxMallController extends BaseController { | |||||
| return new ResultData(Result.SUCCESS, "查询成功", mall); | return new ResultData(Result.SUCCESS, "查询成功", mall); | ||||
| } | } | ||||
| @AuthIgnore | |||||
| @ApiOperation("获取后端版本号") | |||||
| @GetMapping("/version") | |||||
| public ResultData version() { | |||||
| return new ResultData(version); | |||||
| } | |||||
| /** | /** | ||||
| * 微信消息服务验证 | * 微信消息服务验证 | ||||
| * @param response | * @param response | ||||
| @@ -43,4 +43,6 @@ pay: | |||||
| jasypt: | jasypt: | ||||
| encryptor: | encryptor: | ||||
| password: oRqdnDbK5pj3eMmB | |||||
| password: oRqdnDbK5pj3eMmB | |||||
| version: @project.version@ | |||||
| @@ -14,6 +14,7 @@ import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.beans.factory.annotation.Value; | |||||
| import org.springframework.web.bind.annotation.GetMapping; | import org.springframework.web.bind.annotation.GetMapping; | ||||
| import org.springframework.web.bind.annotation.RequestMapping; | import org.springframework.web.bind.annotation.RequestMapping; | ||||
| import org.springframework.web.bind.annotation.RestController; | import org.springframework.web.bind.annotation.RestController; | ||||
| @@ -27,6 +28,9 @@ import java.util.Map; | |||||
| public class WxMallController extends BaseController { | public class WxMallController extends BaseController { | ||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
| @Value("${version}") | |||||
| private String version; | |||||
| @Autowired | @Autowired | ||||
| private WxMallService wxMallService; | private WxMallService wxMallService; | ||||
| @@ -68,5 +72,12 @@ public class WxMallController extends BaseController { | |||||
| return new ResultData(Result.SUCCESS, "查询成功", mall); | return new ResultData(Result.SUCCESS, "查询成功", mall); | ||||
| } | } | ||||
| @AuthIgnore | |||||
| @ApiOperation("获取后端版本号") | |||||
| @GetMapping("/version") | |||||
| public ResultData version() { | |||||
| return new ResultData(version); | |||||
| } | |||||
| } | } | ||||
| @@ -43,4 +43,6 @@ pay: | |||||
| jasypt: | jasypt: | ||||
| encryptor: | encryptor: | ||||
| password: oRqdnDbK5pj3eMmB | |||||
| password: oRqdnDbK5pj3eMmB | |||||
| version: @project.version@ | |||||
| @@ -56,6 +56,8 @@ public enum ErrorCode{ | |||||
| BUSER_NOT_IN_APP(2005, "用户不是此app用户"), | BUSER_NOT_IN_APP(2005, "用户不是此app用户"), | ||||
| KAPCHA_NOT_VALID(2006, "验证码已失效"), | KAPCHA_NOT_VALID(2006, "验证码已失效"), | ||||
| KAPCHA_NOT_EQUAL(2007, "验证码不正确"), | KAPCHA_NOT_EQUAL(2007, "验证码不正确"), | ||||
| USER_NAME_IS_FOUND(2008,"用户名已存在"), | |||||
| USER_PHONE_IS_FOUND(2009,"手机号已存在"), | |||||
| /** | /** | ||||
| * 商场/商户 | * 商场/商户 | ||||
| @@ -69,11 +71,19 @@ public enum ErrorCode{ | |||||
| /** | /** | ||||
| * 券 | * 券 | ||||
| */ | */ | ||||
| COUPON_IS_EMPTY(2020, "券不存在"), | |||||
| COUPON_IS_NOT_FREE(2021, "券不免费"), | |||||
| COUPON_IS_EMPTY(2020, "此券不存在"), | |||||
| COUPON_IS_NOT_FREE(2021, "此券不免费"), | |||||
| COUPON_IS_TAKE_OFF(2022, "此券已下架"), | COUPON_IS_TAKE_OFF(2022, "此券已下架"), | ||||
| COUPON_IS_EXPIRED(2023, "此券已过期"), | |||||
| COUPON_IS_SELL_OUT(2024, "此券已售罄"), | |||||
| COUPON_TYPE_IS_NOT_ACTIVE(2025, "此券不能用于主动领取"), | |||||
| COUPON_TYPE_IS_NOT_PASSIVE(2026, "此券不能用于定向投放"), | |||||
| COUPON_CHANNEL_IS_EXISTED(2027, "此券已投放过"), | |||||
| COUPON_SEND_IS_EXISTED(2028, "此券已经添加到该渠道"), | |||||
| COUPON_CHANNEL_IS_EXISTED(2023, "券已投放过"), | |||||
| /** | /** | ||||
| * 车流 2040 | * 车流 2040 | ||||
| */ | */ | ||||
| @@ -67,7 +67,10 @@ public class MallUserInfo implements Serializable { | |||||
| private Integer isAdmin; | private Integer isAdmin; | ||||
| @io.swagger.annotations.ApiModelProperty(value="昵称",name="nickName") | @io.swagger.annotations.ApiModelProperty(value="昵称",name="nickName") | ||||
| private String nickName; | private String nickName; | ||||
| @io.swagger.annotations.ApiModelProperty(value="手机",name="phone") | |||||
| private String phone; | |||||
| @Transient | @Transient | ||||
| private Long roleId; | private Long roleId; | ||||
| @@ -82,6 +85,9 @@ public class MallUserInfo implements Serializable { | |||||
| //拥有的菜单权限 | //拥有的菜单权限 | ||||
| @Transient | @Transient | ||||
| private String menus; | private String menus; | ||||
| @Transient | |||||
| private String captcha; | |||||
| public String getMenus() { | public String getMenus() { | ||||
| return menus; | return menus; | ||||
| @@ -179,9 +185,21 @@ public class MallUserInfo implements Serializable { | |||||
| this.roleId = roleId; | this.roleId = roleId; | ||||
| } | } | ||||
| public String getCaptcha() { | |||||
| return captcha; | |||||
| } | |||||
| public void setCaptcha(String captcha) { | |||||
| this.captcha = captcha; | |||||
| } | |||||
| public String getPhone() { | |||||
| return phone; | |||||
| } | |||||
| public void setPhone(String phone) { | |||||
| this.phone = phone; | |||||
| } | |||||
| public static enum Field | public static enum Field | ||||
| { | { | ||||
| @@ -41,20 +41,19 @@ public class WxTemplateMsg implements Serializable { | |||||
| } | } | ||||
| /*租户ID**/ | |||||
| /**租户ID**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") | @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") | ||||
| private String tenantId; | private String tenantId; | ||||
| /*模板ID**/ | |||||
| /**模板ID**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="模板ID",name="templateId") | @io.swagger.annotations.ApiModelProperty(value="模板ID",name="templateId") | ||||
| private String templateId; | private String templateId; | ||||
| /*模板类型1:支付成功消息2:退款申请成功消息**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="模板类型1:支付成功消息2:退款申请成功消息",name="type") | |||||
| /**模板类型1:核销成功消息, 2:核销失败消息**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="模板类型1:核销成功消息,2:核销失败消息",name="type") | |||||
| private Integer type; | private Integer type; | ||||
| /*创建时间**/ | |||||
| /**创建时间**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | ||||
| private Date createDate; | private Date createDate; | ||||
| /*更新时间**/ | |||||
| /**更新时间**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | ||||
| private Date updateDate; | private Date updateDate; | ||||
| public String getTenantId() { | public String getTenantId() { | ||||
| @@ -93,11 +92,11 @@ public class WxTemplateMsg implements Serializable { | |||||
| public static enum Field | public static enum Field | ||||
| { | { | ||||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | ||||
| ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") | |||||
| ,TemplateId_ASC("`templateId` ASC"),TemplateId_DESC("`templateId` DESC") | |||||
| ,TenantId_ASC("`tenant_id` ASC"),TenantId_DESC("`tenant_id` DESC") | |||||
| ,TemplateId_ASC("`template_id` ASC"),TemplateId_DESC("`template_id` DESC") | |||||
| ,Type_ASC("`type` ASC"),Type_DESC("`type` DESC") | ,Type_ASC("`type` ASC"),Type_DESC("`type` DESC") | ||||
| ,CreateDate_ASC("`createDate` ASC"),CreateDate_DESC("`createDate` DESC") | |||||
| ,UpdateDate_ASC("`updateDate` ASC"),UpdateDate_DESC("`updateDate` DESC") | |||||
| ,CreateDate_ASC("`create_date` ASC"),CreateDate_DESC("`create_date` DESC") | |||||
| ,UpdateDate_ASC("`update_date` ASC"),UpdateDate_DESC("`update_date` DESC") | |||||
| ; | ; | ||||
| private String value; | private String value; | ||||
| Field(String value){ | Field(String value){ | ||||
| @@ -130,6 +129,8 @@ public class WxTemplateMsg implements Serializable { | |||||
| sb.append(","); | sb.append(","); | ||||
| sb.append(fields[k].toString()); | sb.append(fields[k].toString()); | ||||
| } | } | ||||
| this.sortColumns = sb.toString(); | |||||
| } | } | ||||
| @@ -0,0 +1,37 @@ | |||||
| package com.simple.enums; | |||||
| /** | |||||
| * Created by Stormeye on 2018/08/09. | |||||
| */ | |||||
| public enum EnumCouponInjectSendType { | |||||
| // 0:立即发送 1:定时发送 | |||||
| IMMEDIATE(0, "立即发送"), | |||||
| TIMING(1, "定时发送") | |||||
| ; | |||||
| public static EnumCouponInjectSendType getEnum(Integer code) { | |||||
| for (EnumCouponInjectSendType value : values()) { | |||||
| if (value.getCode().equals(code)) { | |||||
| return value; | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| private Integer code; | |||||
| private String message; | |||||
| EnumCouponInjectSendType(Integer code, String message) { | |||||
| this.code = code; | |||||
| this.message = message; | |||||
| } | |||||
| public Integer getCode() { | |||||
| return code; | |||||
| } | |||||
| public String getMessage() { | |||||
| return message; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,37 @@ | |||||
| package com.simple.enums; | |||||
| /** | |||||
| * Created by Stormeye on 2018/08/09. | |||||
| */ | |||||
| public enum EnumCouponSendSendType { | |||||
| // 2:停车发券 3:核销发券 | |||||
| CAR_STOP(2, "停车发券"), | |||||
| COUPON_VERIFY(3, "核销发券") | |||||
| ; | |||||
| public static EnumCouponSendSendType getEnum(Integer code) { | |||||
| for (EnumCouponSendSendType value : values()) { | |||||
| if (value.getCode().equals(code)) { | |||||
| return value; | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| private Integer code; | |||||
| private String message; | |||||
| EnumCouponSendSendType(Integer code, String message) { | |||||
| this.code = code; | |||||
| this.message = message; | |||||
| } | |||||
| public Integer getCode() { | |||||
| return code; | |||||
| } | |||||
| public String getMessage() { | |||||
| return message; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,37 @@ | |||||
| package com.simple.enums; | |||||
| /** | |||||
| * Created by Stormeye on 2018/08/09. | |||||
| */ | |||||
| public enum EnumCouponSendStatus { | |||||
| // 0:有效 1:无效 | |||||
| VALID(0,"有效"), | |||||
| INVALID(1, "无效") | |||||
| ; | |||||
| public static EnumCouponSendStatus getEnum(Integer code) { | |||||
| for (EnumCouponSendStatus value : values()) { | |||||
| if (value.getCode().equals(code)) { | |||||
| return value; | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| private Integer code; | |||||
| private String message; | |||||
| EnumCouponSendStatus(Integer code, String message) { | |||||
| this.code = code; | |||||
| this.message = message; | |||||
| } | |||||
| public Integer getCode() { | |||||
| return code; | |||||
| } | |||||
| public String getMessage() { | |||||
| return message; | |||||
| } | |||||
| } | |||||
| @@ -5,9 +5,9 @@ package com.simple.enums; | |||||
| */ | */ | ||||
| public enum EnumCouponSendType { | public enum EnumCouponSendType { | ||||
| // 2:停车发券 3:核销发券 | |||||
| CAR_STOP(2, "停车发券"), | |||||
| COUPON_VERIFY(3, "核销发券") | |||||
| // 1:主动领取 2:定向投放 | |||||
| ACTIVE(1,"主动领取"), | |||||
| PASSIVE(2, "定向投放") | |||||
| ; | ; | ||||
| public static EnumCouponSendType getEnum(Integer code) { | public static EnumCouponSendType getEnum(Integer code) { | ||||
| @@ -0,0 +1,38 @@ | |||||
| package com.simple.enums; | |||||
| /** | |||||
| * Created by Stormeye on 2018/08/09. | |||||
| */ | |||||
| public enum EnumCouponValidType { | |||||
| // 1-时间范围 ;2-领取后时长; | |||||
| BETWEEN_TWO_TIME(1, "时间范围"), | |||||
| DAYS_AFTER_RECEIVING(2, "领取后天数"), | |||||
| ; | |||||
| public static EnumCouponValidType getEnum(Integer code) { | |||||
| for (EnumCouponValidType value : values()) { | |||||
| if (value.getCode().equals(code)) { | |||||
| return value; | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| private Integer code; | |||||
| private String message; | |||||
| EnumCouponValidType(Integer code, String message) { | |||||
| this.code = code; | |||||
| this.message = message; | |||||
| } | |||||
| public Integer getCode() { | |||||
| return code; | |||||
| } | |||||
| public String getMessage() { | |||||
| return message; | |||||
| } | |||||
| } | |||||
| @@ -5,11 +5,10 @@ package com.simple.enums; | |||||
| */ | */ | ||||
| public enum EnumTemplateType { | public enum EnumTemplateType { | ||||
| // 1-支付成功消息, 2-支付失败消息 3-退款消息 | |||||
| // 1-核销成功消息, 2-核销失败消息 | |||||
| PAY_SUCCESS(1, "订单支付成功通知"), | |||||
| PAY_FAIL(2, "支付失败通知"), | |||||
| REFUND(3, "退款通知") | |||||
| VERIFY_SUCCESS(1, "核销成功消息"), | |||||
| VERIFY_FAIL(2, "核销失败消息") | |||||
| ; | ; | ||||
| public static EnumTemplateType getEnum(Integer code) { | public static EnumTemplateType getEnum(Integer code) { | ||||
| @@ -5,6 +5,7 @@ import com.simple.domain.po.MallUserInfo; | |||||
| import org.apache.ibatis.annotations.Param; | import org.apache.ibatis.annotations.Param; | ||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | |||||
| public interface MallUserInfoMapper extends CommonMapper<MallUserInfo, String> { | public interface MallUserInfoMapper extends CommonMapper<MallUserInfo, String> { | ||||
| @@ -14,6 +15,8 @@ public interface MallUserInfoMapper extends CommonMapper<MallUserInfo, String> { | |||||
| Integer hasButtonPermission(@Param("userId") Long userId, @Param("permission") String permission); | Integer hasButtonPermission(@Param("userId") Long userId, @Param("permission") String permission); | ||||
| long cntByUserName(Map<String,Object> params); | |||||
| } | } | ||||
| @@ -6,7 +6,6 @@ import com.simple.domain.po.WxCUserBasicInfo; | |||||
| import com.simple.domain.vo.CUserBaseVo; | import com.simple.domain.vo.CUserBaseVo; | ||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | |||||
| public interface WxCUserBasicInfoMapper extends CommonMapper<WxCUserBasicInfo, String> { | public interface WxCUserBasicInfoMapper extends CommonMapper<WxCUserBasicInfo, String> { | ||||
| @@ -20,4 +19,6 @@ public interface WxCUserBasicInfoMapper extends CommonMapper<WxCUserBasicInfo, S | |||||
| long findCountByAge(WxCUserBasicInfoDto dto); | long findCountByAge(WxCUserBasicInfoDto dto); | ||||
| long findCount(WxCUserBasicInfoDto dto); | |||||
| } | } | ||||
| @@ -67,7 +67,10 @@ public interface MallUserInfoService { | |||||
| * @return 是否有权限(true: 有| false: 没有) | * @return 是否有权限(true: 有| false: 没有) | ||||
| */ | */ | ||||
| boolean hasButtonPermission(Long userId, String permission); | boolean hasButtonPermission(Long userId, String permission); | ||||
| boolean cntByUserName(String username, Long id); | |||||
| boolean cntByUserPhone(String phone, Long id); | |||||
| } | } | ||||
| @@ -9,7 +9,6 @@ import org.springframework.web.multipart.MultipartFile; | |||||
| import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
| import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | |||||
| public interface WxCUserBasicInfoService { | public interface WxCUserBasicInfoService { | ||||
| @@ -83,4 +82,6 @@ public interface WxCUserBasicInfoService { | |||||
| ResultData importTemplate(MultipartFile file, String tenantId); | ResultData importTemplate(MultipartFile file, String tenantId); | ||||
| long findCount(WxCUserBasicInfoDto dto); | |||||
| } | } | ||||
| @@ -2,6 +2,7 @@ package com.simple.service; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.simple.common.ResultData; | import com.simple.common.ResultData; | ||||
| import com.simple.domain.po.WxAppinfo; | |||||
| import com.simple.domain.po.WxCouponOrder; | import com.simple.domain.po.WxCouponOrder; | ||||
| import com.simple.domain.po.WxMerchantBUser; | import com.simple.domain.po.WxMerchantBUser; | ||||
| import com.simple.domain.po.WxOrder; | import com.simple.domain.po.WxOrder; | ||||
| @@ -78,6 +79,13 @@ public interface WxCouponOrderService { | |||||
| */ | */ | ||||
| void shareAfterVerify(WxCouponOrder couponOrder); | void shareAfterVerify(WxCouponOrder couponOrder); | ||||
| /** | |||||
| * 核销模板消息 | |||||
| * @param couponOrder | |||||
| * @param bUser | |||||
| */ | |||||
| void sendVerifyMsg(WxCouponOrder couponOrder, WxMerchantBUser bUser); | |||||
| /** | /** | ||||
| * 根据日期 b用户查券list | * 根据日期 b用户查券list | ||||
| * | * | ||||
| @@ -1,9 +1,8 @@ | |||||
| package com.simple.service; | package com.simple.service; | ||||
| import java.util.*; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.simple.domain.po.WxCouponSend; | import com.simple.domain.po.WxCouponSend; | ||||
| import com.simple.enums.EnumCouponSendType; | |||||
| import com.simple.enums.EnumCouponSendSendType; | |||||
| public interface WxCouponSendService { | public interface WxCouponSendService { | ||||
| @@ -45,7 +44,7 @@ public interface WxCouponSendService { | |||||
| * @param cUserId | * @param cUserId | ||||
| * @param type 2:停车发券 3:核销发券 | * @param type 2:停车发券 3:核销发券 | ||||
| */ | */ | ||||
| void sendCouponToUser(String tenantId, Long cUserId, EnumCouponSendType type); | |||||
| void sendCouponToUser(String tenantId, Long cUserId, EnumCouponSendSendType type); | |||||
| void updateStatusByCouponId(Long couponId,String tenantId,int status); | void updateStatusByCouponId(Long couponId,String tenantId,int status); | ||||
| @@ -4,6 +4,7 @@ import java.util.*; | |||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.simple.common.ResultData; | |||||
| import com.simple.domain.po.WxCUser; | import com.simple.domain.po.WxCUser; | ||||
| import com.simple.domain.po.WxCouponOrder; | import com.simple.domain.po.WxCouponOrder; | ||||
| import com.simple.domain.po.WxOrder; | import com.simple.domain.po.WxOrder; | ||||
| @@ -60,8 +61,13 @@ public interface WxOrderService { | |||||
| * @param enumOrderStatus | * @param enumOrderStatus | ||||
| */ | */ | ||||
| int updateOrderStatus(WxOrder updateOrder, EnumOrderStatus enumOrderStatus); | int updateOrderStatus(WxOrder updateOrder, EnumOrderStatus enumOrderStatus); | ||||
| /** | |||||
| /** | |||||
| * 订单关单 | |||||
| */ | |||||
| ResultData orderClose(WxOrder order); | |||||
| /** | |||||
| * 根据Id获得实体 | * 根据Id获得实体 | ||||
| * | * | ||||
| * @param id | * @param id | ||||
| @@ -109,7 +109,5 @@ public interface WxPayOrderService { | |||||
| */ | */ | ||||
| void deleteById(Long id); | void deleteById(Long id); | ||||
| void sendPaySuccess(); | |||||
| } | } | ||||
| @@ -3,10 +3,14 @@ package com.simple.service.impl; | |||||
| import com.alibaba.fastjson.JSON; | import com.alibaba.fastjson.JSON; | ||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.simple.common.ErrorCode; | |||||
| import com.simple.common.IdWorker; | import com.simple.common.IdWorker; | ||||
| import com.simple.common.Result; | import com.simple.common.Result; | ||||
| import com.simple.common.ResultData; | import com.simple.common.ResultData; | ||||
| import com.simple.domain.po.*; | import com.simple.domain.po.*; | ||||
| import com.simple.enums.EnumCouponSendType; | |||||
| import com.simple.enums.EnumCouponStatus; | |||||
| import com.simple.enums.EnumCouponValidType; | |||||
| import com.simple.mapper.CouponInjectMapper; | import com.simple.mapper.CouponInjectMapper; | ||||
| import com.simple.service.*; | import com.simple.service.*; | ||||
| import org.apache.commons.lang.time.DateUtils; | import org.apache.commons.lang.time.DateUtils; | ||||
| @@ -65,17 +69,21 @@ public class CouponInjectServiceImpl implements CouponInjectService { | |||||
| @Override | @Override | ||||
| public ResultData add(CouponInject record) { | public ResultData add(CouponInject record) { | ||||
| ResultData resultData = new ResultData(); | |||||
| WxCoupon wxCoupon = wxCouponService.getById(record.getCouponId()); | WxCoupon wxCoupon = wxCouponService.getById(record.getCouponId()); | ||||
| if (wxCoupon.getValidType() == 1) { //时间范围 | |||||
| if (wxCoupon.getValidType() == EnumCouponValidType.BETWEEN_TWO_TIME.getCode()) { //时间范围 | |||||
| if (new Date().after(wxCoupon.getValidEndDate())) { | if (new Date().after(wxCoupon.getValidEndDate())) { | ||||
| return new ResultData(Result.ERROR,"已过期"); | |||||
| return new ResultData(ErrorCode.COUPON_IS_EXPIRED); | |||||
| } | } | ||||
| } | } | ||||
| if(wxCoupon.getStatus()!=0||wxCoupon.getSendType()!=1){ | |||||
| return new ResultData(Result.ERROR,"券状态有问题,不能投放"); | |||||
| if(wxCoupon.getStatus() != EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode()){ | |||||
| return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF); | |||||
| } | |||||
| if(wxCoupon.getSendType()!=EnumCouponSendType.PASSIVE.getCode()) { | |||||
| return new ResultData(ErrorCode.COUPON_TYPE_IS_NOT_PASSIVE); | |||||
| } | } | ||||
| //解析前台tags,并转换json | //解析前台tags,并转换json | ||||
| String[] arys = record.getTags().split(","); | String[] arys = record.getTags().split(","); | ||||
| List<Long> tagids = new ArrayList<>(); | List<Long> tagids = new ArrayList<>(); | ||||
| @@ -99,7 +107,7 @@ public class CouponInjectServiceImpl implements CouponInjectService { | |||||
| } | } | ||||
| int inventory = wxCoupon.getRemainInventory();//库存数量 | int inventory = wxCoupon.getRemainInventory();//库存数量 | ||||
| if(cUsers.size()>inventory){ | if(cUsers.size()>inventory){ | ||||
| return new ResultData(Result.ERROR,"库存不足"); | |||||
| return new ResultData(ErrorCode.COUPON_IS_SELL_OUT); | |||||
| } | } | ||||
| record.setCouponName(wxCoupon.getTitle()); | record.setCouponName(wxCoupon.getTitle()); | ||||
| record.setSendAmount(cUsers.size()); | record.setSendAmount(cUsers.size()); | ||||
| @@ -131,7 +139,7 @@ public class CouponInjectServiceImpl implements CouponInjectService { | |||||
| wxCouponOrder.setCUserId(tempCUser.getId()); | wxCouponOrder.setCUserId(tempCUser.getId()); | ||||
| wxCouponOrder.setCouponPrice(0); | wxCouponOrder.setCouponPrice(0); | ||||
| wxCouponOrder.setCreateDate(new Date()); | wxCouponOrder.setCreateDate(new Date()); | ||||
| if (wxCoupon.getValidType() == 1) { //时间范围区间 | |||||
| if (wxCoupon.getValidType() == EnumCouponValidType.BETWEEN_TWO_TIME.getCode()) { //时间范围区间 | |||||
| wxCouponOrder.setExpiredTime(wxCoupon.getValidEndDate()); | wxCouponOrder.setExpiredTime(wxCoupon.getValidEndDate()); | ||||
| } else { | } else { | ||||
| Date date = DateUtils.addDays(new Date(), wxCoupon.getValidDays()); | Date date = DateUtils.addDays(new Date(), wxCoupon.getValidDays()); | ||||
| @@ -1,7 +1,6 @@ | |||||
| package com.simple.service.impl; | package com.simple.service.impl; | ||||
| import com.alibaba.fastjson.JSONObject; | import com.alibaba.fastjson.JSONObject; | ||||
| import com.google.gson.JsonObject; | |||||
| import com.simple.domain.po.WxMall; | import com.simple.domain.po.WxMall; | ||||
| import com.simple.domain.po.WxMerchant; | import com.simple.domain.po.WxMerchant; | ||||
| import com.simple.domain.po.WxMerchantTradeDaily; | import com.simple.domain.po.WxMerchantTradeDaily; | ||||
| @@ -13,12 +12,10 @@ import com.simple.utils.DateUtils; | |||||
| import com.simple.utils.HashUtil; | import com.simple.utils.HashUtil; | ||||
| import com.simple.utils.HttpUtil; | import com.simple.utils.HttpUtil; | ||||
| import org.apache.log4j.Logger; | import org.apache.log4j.Logger; | ||||
| import org.apache.poi.ss.usermodel.DateUtil; | |||||
| import org.apache.shiro.codec.Base64; | import org.apache.shiro.codec.Base64; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import java.io.UnsupportedEncodingException; | |||||
| import java.math.BigDecimal; | import java.math.BigDecimal; | ||||
| import java.util.*; | import java.util.*; | ||||
| import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||
| @@ -269,11 +266,13 @@ public class DataTowerServiceImpl implements DataTowerService { | |||||
| Map<String,String> params=new HashMap<>(); | Map<String,String> params=new HashMap<>(); | ||||
| params.put("username",username); | params.put("username",username); | ||||
| params.put("authVal",authVal); | params.put("authVal",authVal); | ||||
| String token = HttpUtil.doPost(wxMall.getWiwideUrl(), params); | |||||
| String wiwideUrl = wxMall.getWiwideUrl(); | |||||
| String token = HttpUtil.doPost(wiwideUrl+"/login/auth", params); | |||||
| Map<String, Object> datamap = new HashMap<>(); | Map<String, Object> datamap = new HashMap<>(); | ||||
| datamap.put("token",JSONObject.parseObject(token).get("data")); | datamap.put("token",JSONObject.parseObject(token).get("data")); | ||||
| datamap.put("url",wiwideUrl); | |||||
| return datamap; | return datamap; | ||||
| } | } | ||||
| @@ -12,6 +12,9 @@ import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import org.springframework.transaction.annotation.Transactional; | import org.springframework.transaction.annotation.Transactional; | ||||
| import java.util.HashMap; | |||||
| import java.util.Map; | |||||
| @Service | @Service | ||||
| public class MallUserInfoServiceImpl implements MallUserInfoService { | public class MallUserInfoServiceImpl implements MallUserInfoService { | ||||
| @@ -79,7 +82,21 @@ public class MallUserInfoServiceImpl implements MallUserInfoService { | |||||
| public boolean hasButtonPermission(Long userId, String permission) { | public boolean hasButtonPermission(Long userId, String permission) { | ||||
| return mallUserInfoMapper.hasButtonPermission(userId, permission) == null ? false : true; | return mallUserInfoMapper.hasButtonPermission(userId, permission) == null ? false : true; | ||||
| } | } | ||||
| @Override | |||||
| public boolean cntByUserName(String username, Long id) { | |||||
| Map<String,Object> params=new HashMap<>(); | |||||
| params.put("username",username); | |||||
| params.put("id",id); | |||||
| return mallUserInfoMapper.cntByUserName(params)>0?true:false; | |||||
| } | |||||
| @Override | |||||
| public boolean cntByUserPhone(String phone, Long id) { | |||||
| Map<String,Object> params=new HashMap<>(); | |||||
| params.put("phone",phone); | |||||
| params.put("id",id); | |||||
| return mallUserInfoMapper.cntByUserName(params)>0?true:false; | |||||
| } | |||||
| } | } | ||||
| @@ -336,5 +336,10 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { | |||||
| return new ResultData(Result.SUCCESS, "导入成功"); | return new ResultData(Result.SUCCESS, "导入成功"); | ||||
| } | } | ||||
| @Override | |||||
| public long findCount(WxCUserBasicInfoDto dto) { | |||||
| return wxCUserBasicInfoMapper.findCount(dto); | |||||
| } | |||||
| } | } | ||||
| @@ -3,8 +3,11 @@ package com.simple.service.impl; | |||||
| import cn.afterturn.easypoi.excel.ExcelExportUtil; | import cn.afterturn.easypoi.excel.ExcelExportUtil; | ||||
| import cn.afterturn.easypoi.excel.entity.ExportParams; | import cn.afterturn.easypoi.excel.entity.ExportParams; | ||||
| import cn.afterturn.easypoi.excel.entity.enmus.ExcelType; | import cn.afterturn.easypoi.excel.entity.enmus.ExcelType; | ||||
| import cn.binarywang.wx.miniapp.api.WxMaService; | |||||
| import cn.binarywang.wx.miniapp.bean.WxMaTemplateMessage; | |||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.google.common.collect.Lists; | |||||
| import com.simple.common.ErrorCode; | import com.simple.common.ErrorCode; | ||||
| import com.simple.common.IdWorker; | import com.simple.common.IdWorker; | ||||
| import com.simple.common.ResultData; | import com.simple.common.ResultData; | ||||
| @@ -13,15 +16,13 @@ import com.simple.domain.vo.CUserDateAmountVo; | |||||
| import com.simple.domain.vo.WxCouponOrderBVo; | import com.simple.domain.vo.WxCouponOrderBVo; | ||||
| import com.simple.domain.vo.WxCouponOrderCVo; | import com.simple.domain.vo.WxCouponOrderCVo; | ||||
| import com.simple.domain.vo.WxCouponOrderCarCVo; | import com.simple.domain.vo.WxCouponOrderCarCVo; | ||||
| import com.simple.enums.EnumCouponOrderStatus; | |||||
| import com.simple.enums.EnumCouponSendType; | |||||
| import com.simple.enums.EnumPayShare; | |||||
| import com.simple.enums.EnumPayStatus; | |||||
| import com.simple.enums.*; | |||||
| import com.simple.exception.MallinkException; | import com.simple.exception.MallinkException; | ||||
| import com.simple.mapper.*; | import com.simple.mapper.*; | ||||
| import com.simple.service.*; | import com.simple.service.*; | ||||
| import com.simple.utils.DataUtil; | |||||
| import com.simple.utils.DateUtils; | import com.simple.utils.DateUtils; | ||||
| import com.simple.utils.MaUtil; | |||||
| import me.chanjar.weixin.common.error.WxErrorException; | |||||
| import org.apache.log4j.Logger; | import org.apache.log4j.Logger; | ||||
| import org.apache.poi.ss.usermodel.Workbook; | import org.apache.poi.ss.usermodel.Workbook; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| @@ -40,7 +41,7 @@ import java.util.*; | |||||
| public class WxCouponOrderServiceImpl implements WxCouponOrderService { | public class WxCouponOrderServiceImpl implements WxCouponOrderService { | ||||
| private Logger logger = Logger.getLogger(WxCouponOrderServiceImpl.class); | private Logger logger = Logger.getLogger(WxCouponOrderServiceImpl.class); | ||||
| @Autowired | |||||
| @Autowired | |||||
| WxCouponOrderMapper wxCouponOrderMapper; | WxCouponOrderMapper wxCouponOrderMapper; | ||||
| @Autowired | @Autowired | ||||
| @@ -70,6 +71,15 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| @Autowired | @Autowired | ||||
| WxMallMapper wxMallMapper; | WxMallMapper wxMallMapper; | ||||
| @Autowired | |||||
| WxTemplateMsgMapper wxTemplateMsgMapper; | |||||
| @Autowired | |||||
| WxCouponMapper wxCouponMapper; | |||||
| @Autowired | |||||
| WxAppinfoService wxAppinfoService; | |||||
| @Override | @Override | ||||
| public PageInfo<WxCouponOrder> listAsPage(WxCouponOrder record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxCouponOrder> listAsPage(WxCouponOrder record, Integer pageIndex, Integer pageSize) { | ||||
| @@ -86,7 +96,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| if (record.getId() == null) { | if (record.getId() == null) { | ||||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | ||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| record.setId(idWorker.nextId()); | |||||
| record.setId(idWorker.nextId()); | |||||
| wxCouponOrderMapper.insertSelective(record); | wxCouponOrderMapper.insertSelective(record); | ||||
| } else { | } else { | ||||
| wxCouponOrderMapper.updateByPrimaryKeySelective(record); | wxCouponOrderMapper.updateByPrimaryKeySelective(record); | ||||
| @@ -135,8 +145,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| } catch (ParseException e) { | } catch (ParseException e) { | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR); | return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR); | ||||
| } | } | ||||
| } | |||||
| else { | |||||
| } else { | |||||
| try { | try { | ||||
| startDate = fmt.parse(date); | startDate = fmt.parse(date); | ||||
| } catch (ParseException e) { | } catch (ParseException e) { | ||||
| @@ -144,7 +153,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| } | } | ||||
| Calendar cal = Calendar.getInstance(); | Calendar cal = Calendar.getInstance(); | ||||
| cal.setTime(startDate); | cal.setTime(startDate); | ||||
| cal.add(Calendar.DATE,1); | |||||
| cal.add(Calendar.DATE, 1); | |||||
| endDate = cal.getTime(); | endDate = cal.getTime(); | ||||
| } | } | ||||
| @@ -157,7 +166,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| if (pageIndex == null || pageSize == null) { | if (pageIndex == null || pageSize == null) { | ||||
| List<WxCouponOrder> list; | List<WxCouponOrder> list; | ||||
| if(isVerified) | |||||
| if (isVerified) | |||||
| list = wxCouponOrderMapper.findListOfVerifiedByDate(dateMap); | list = wxCouponOrderMapper.findListOfVerifiedByDate(dateMap); | ||||
| else | else | ||||
| list = wxCouponOrderMapper.findListOfOrderedByDate(dateMap); | list = wxCouponOrderMapper.findListOfOrderedByDate(dateMap); | ||||
| @@ -167,8 +176,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| total_price = total_price + couponOrder.getCouponPrice(); | total_price = total_price + couponOrder.getCouponPrice(); | ||||
| } | } | ||||
| resultMap.put("amount", total_price); | resultMap.put("amount", total_price); | ||||
| } | |||||
| else { | |||||
| } else { | |||||
| if (isVerified) | if (isVerified) | ||||
| resultMap.put("list", PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponOrderMapper.findListOfVerifiedByDateForBUser(dateMap))); | resultMap.put("list", PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponOrderMapper.findListOfVerifiedByDateForBUser(dateMap))); | ||||
| else | else | ||||
| @@ -196,8 +204,8 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| @Override | @Override | ||||
| public ResultData detailCUserVo(Long cUserId, String couponOrderId) { | public ResultData detailCUserVo(Long cUserId, String couponOrderId) { | ||||
| WxCUser wxCuser = wxCUserMapper.selectByPrimaryKey(cUserId); | WxCUser wxCuser = wxCUserMapper.selectByPrimaryKey(cUserId); | ||||
| if(wxCuser == null){ | |||||
| logger.error("用户不存在:"+ cUserId); | |||||
| if (wxCuser == null) { | |||||
| logger.error("用户不存在:" + cUserId); | |||||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | throw new MallinkException(ErrorCode.USER_IS_EMPTY); | ||||
| } | } | ||||
| @@ -215,8 +223,8 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| @Override | @Override | ||||
| public ResultData detailBUserVo(Long bUserId, String couponOrderId) { | public ResultData detailBUserVo(Long bUserId, String couponOrderId) { | ||||
| WxMerchantBUser wxMerchantBUser = wxMerchantBUserMapper.selectByPrimaryKey(bUserId); | WxMerchantBUser wxMerchantBUser = wxMerchantBUserMapper.selectByPrimaryKey(bUserId); | ||||
| if(wxMerchantBUser == null){ | |||||
| logger.error("用户不存在:"+ bUserId); | |||||
| if (wxMerchantBUser == null) { | |||||
| logger.error("用户不存在:" + bUserId); | |||||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | throw new MallinkException(ErrorCode.USER_IS_EMPTY); | ||||
| } | } | ||||
| @@ -250,21 +258,21 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| WxMall wxMall = new WxMall(); | WxMall wxMall = new WxMall(); | ||||
| wxMall.setTenantId(tenantId); | wxMall.setTenantId(tenantId); | ||||
| wxMall = wxMallMapper.findList(wxMall).get(0); | wxMall = wxMallMapper.findList(wxMall).get(0); | ||||
| String filepath="./uploads/"; | |||||
| String filepath = "./uploads/"; | |||||
| File savefile = new File(filepath); | File savefile = new File(filepath); | ||||
| if (!savefile.exists()) { | if (!savefile.exists()) { | ||||
| savefile.mkdirs(); | savefile.mkdirs(); | ||||
| } | } | ||||
| Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("","",ExcelType.XSSF), WxCouponOrderBVo.class, list); | |||||
| Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("", "", ExcelType.XSSF), WxCouponOrderBVo.class, list); | |||||
| FileOutputStream fos = null; | FileOutputStream fos = null; | ||||
| try { | try { | ||||
| String filename=wxMall.getName()+ DateUtils.getSystemTime("yyyyMMDDHHmmss") +".xlsx"; | |||||
| filepath=filepath+filename; | |||||
| String filename = wxMall.getName() + DateUtils.getSystemTime("yyyyMMDDHHmmss") + ".xlsx"; | |||||
| filepath = filepath + filename; | |||||
| fos = new FileOutputStream(filepath); | fos = new FileOutputStream(filepath); | ||||
| workbook.write(fos); | workbook.write(fos); | ||||
| fos.close(); | fos.close(); | ||||
| downFile(filepath,filename,response,request); | |||||
| downFile(filepath, filename, response, request); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| e.printStackTrace(); | e.printStackTrace(); | ||||
| } | } | ||||
| @@ -273,8 +281,8 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| } | } | ||||
| public void downFile(String filePath,String filename, HttpServletResponse response, | |||||
| HttpServletRequest req) throws IOException { | |||||
| public void downFile(String filePath, String filename, HttpServletResponse response, | |||||
| HttpServletRequest req) throws IOException { | |||||
| try { | try { | ||||
| response.reset(); | response.reset(); | ||||
| response.setContentType("bin"); | response.setContentType("bin"); | ||||
| @@ -308,21 +316,21 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| public WxCouponOrder verify(Long couponOrderId, Long bUserId) { | public WxCouponOrder verify(Long couponOrderId, Long bUserId) { | ||||
| WxCouponOrder wxCouponOrder = wxCouponOrderMapper.selectByPrimaryKey(couponOrderId); | WxCouponOrder wxCouponOrder = wxCouponOrderMapper.selectByPrimaryKey(couponOrderId); | ||||
| if(wxCouponOrder == null){ | |||||
| logger.error("券ID不存在:"+ couponOrderId); | |||||
| if (wxCouponOrder == null) { | |||||
| logger.error("券ID不存在:" + couponOrderId); | |||||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); | throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); | ||||
| } | } | ||||
| WxMerchantBUser wxMerchantBUser = wxMerchantBUserMapper.selectByPrimaryKey(bUserId.longValue()); | |||||
| if(wxMerchantBUser == null){ | |||||
| logger.error("核销员ID不存在:"+ bUserId); | |||||
| WxMerchantBUser wxMerchantBUser = wxMerchantBUserMapper.selectByPrimaryKey(bUserId.longValue()); | |||||
| if (wxMerchantBUser == null) { | |||||
| logger.error("核销员ID不存在:" + bUserId); | |||||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); | throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); | ||||
| } | } | ||||
| WxOrder wxOrder = wxOrderMapper.selectByPrimaryKey(wxCouponOrder.getOrderId()); | WxOrder wxOrder = wxOrderMapper.selectByPrimaryKey(wxCouponOrder.getOrderId()); | ||||
| if (!wxOrder.getMerchantId().equals(wxMerchantBUser.getMerchantId())){ | |||||
| logger.error("券: couponMerchantId-" + wxOrder.getMerchantId()+"核销: couponMerchantId-"+wxMerchantBUser.getMerchantId()); | |||||
| if (!wxOrder.getMerchantId().equals(wxMerchantBUser.getMerchantId())) { | |||||
| logger.error("券: couponMerchantId-" + wxOrder.getMerchantId() + "核销: couponMerchantId-" + wxMerchantBUser.getMerchantId()); | |||||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); | throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); | ||||
| } | } | ||||
| if (wxCouponOrder.getCouponOrderStatus() == EnumCouponOrderStatus.COUPON_ORDER_OVER_TIME.getCode()) { | if (wxCouponOrder.getCouponOrderStatus() == EnumCouponOrderStatus.COUPON_ORDER_OVER_TIME.getCode()) { | ||||
| @@ -374,23 +382,155 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| WxOrder wxOrder = wxOrderMapper.selectByPrimaryKey(couponOrder.getOrderId()); | WxOrder wxOrder = wxOrderMapper.selectByPrimaryKey(couponOrder.getOrderId()); | ||||
| if (wxOrder != null) { | if (wxOrder != null) { | ||||
| try { | try { | ||||
| wxCouponSendService.sendCouponToUser(bUser.getTenantId(), wxOrder.getCUserId(), EnumCouponSendType.COUPON_VERIFY); | |||||
| wxCouponSendService.sendCouponToUser(bUser.getTenantId(), wxOrder.getCUserId(), EnumCouponSendSendType.COUPON_VERIFY); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error("核销发券: " + e.getMessage()); | logger.error("核销发券: " + e.getMessage()); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /** | |||||
| * 微信模板消息 | |||||
| * | |||||
| * @param couponOrder, bUser | |||||
| */ | |||||
| @Override | |||||
| public void sendVerifyMsg(WxCouponOrder couponOrder, WxMerchantBUser bUser) { | |||||
| // 1. get order info | |||||
| WxOrder order = wxOrderMapper.selectByPrimaryKey(couponOrder.getOrderId()); | |||||
| if (order == null) { | |||||
| logger.error("找不到订单信息"); | |||||
| throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND); | |||||
| } | |||||
| // 2. get coupon info | |||||
| WxCoupon coupon = wxCouponMapper.selectByPrimaryKey(couponOrder.getCouponId()); | |||||
| if (coupon == null) { | |||||
| logger.error("找不到券信息"); | |||||
| throw new MallinkException(ErrorCode.COUPON_IS_EMPTY); | |||||
| } | |||||
| // 3. merchant info | |||||
| WxMerchant merchant = wxMerchantMapper.selectByPrimaryKey(bUser.getMerchantId()); | |||||
| if (merchant == null) { | |||||
| logger.error("找不到商户信息"); | |||||
| throw new MallinkException(ErrorCode.MERCHANT_INFO_NOT_FOUND); | |||||
| } | |||||
| // 4. get user info | |||||
| WxCUser user = wxCUserMapper.selectByPrimaryKey(order.getCUserId()); | |||||
| if (user == null) { | |||||
| logger.error("找不到C端用户"); | |||||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | |||||
| } | |||||
| // 5. get app info | |||||
| WxAppinfo appInfo = wxAppinfoService.getByAppId(user.getAppId()); | |||||
| // 6. get payOrder info | |||||
| WxPayOrder payOrder = null; | |||||
| WxPayOrder payOrderQ = new WxPayOrder(); | |||||
| payOrderQ.setTenantId(couponOrder.getTenantId()); | |||||
| payOrderQ.setOrderId(order.getId()); | |||||
| payOrderQ.setPayOrderStatus(EnumPayStatus.PAY_WAY_SUCCESS.getCode()); | |||||
| List<WxPayOrder> payList = wxPayOrderMapper.select(payOrderQ); | |||||
| if (payList.size() > 0) { | |||||
| payOrder = payList.get(0); | |||||
| } | |||||
| WxMaService wxMaService = MaUtil.getWeappService(appInfo); | |||||
| SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); | |||||
| String couponDetail = ""; | |||||
| if (coupon.getType() == EnumCouponType.COUPON_MANJIAN.getCode()) { | |||||
| couponDetail = "满" + coupon.getUsePriceStr() + "减" + coupon.getPriceStr(); | |||||
| } | |||||
| @Override | |||||
| public List<CUserDateAmountVo> queryPriceTotalGroup(String tenantId, Date startTime, Date endTime) { | |||||
| return wxCouponOrderMapper.queryPriceTotalGroup(tenantId, startTime, endTime); | |||||
| } | |||||
| WxTemplateMsg msg = null; | |||||
| WxMaTemplateMessage templateMessage = null; | |||||
| if (couponOrder.getCouponOrderStatus() == EnumCouponOrderStatus.COUPON_ORDER_USED.getCode()) { | |||||
| WxTemplateMsg msgQ = new WxTemplateMsg(); | |||||
| msgQ.setTenantId(couponOrder.getTenantId()); | |||||
| msgQ.setType(EnumTemplateType.VERIFY_SUCCESS.getCode()); | |||||
| List<WxTemplateMsg> list = wxTemplateMsgMapper.select(msgQ); | |||||
| if (list.size() > 0) { | |||||
| msg = list.get(0); | |||||
| } | |||||
| if (msg == null) { | |||||
| logger.error("找不到模板Id"); | |||||
| throw new MallinkException(ErrorCode.TEMPLATE_NOT_FOUND); | |||||
| } | |||||
| /** | |||||
| * 核销成功 | |||||
| * 核销金额 {{keyword1.DATA}} | |||||
| * 商家名称 {{keyword2.DATA}} | |||||
| * 商品 {{keyword3.DATA}} | |||||
| * 核销时间 {{keyword4.DATA}} | |||||
| * 商品描述 {{keyword5.DATA}} | |||||
| */ | |||||
| templateMessage = WxMaTemplateMessage.builder() | |||||
| .toUser(user.getOpenId()) | |||||
| .formId(payOrder.getPrepayId()) // 微信支付的formId是prepayId | |||||
| .page("pages/index/index") | |||||
| .data(Lists.newArrayList( | |||||
| new WxMaTemplateMessage.Data("keyword1", String.valueOf(coupon.getPrice() * 1.0 / 100) + "元", "#173177"), | |||||
| new WxMaTemplateMessage.Data("keyword2", merchant.getName(), "#173177"), | |||||
| new WxMaTemplateMessage.Data("keyword3", coupon.getTitle(), "#173177"), | |||||
| new WxMaTemplateMessage.Data("keyword4", dateFormat.format(new Date()), "#173177"), | |||||
| new WxMaTemplateMessage.Data("keyword5", couponDetail, "#173177")) | |||||
| ) | |||||
| .templateId(msg.getTemplateId()) | |||||
| .emphasisKeyword("keyword1.DATA") | |||||
| .build(); | |||||
| } else { | |||||
| WxTemplateMsg msgQ = new WxTemplateMsg(); | |||||
| msgQ.setTenantId(couponOrder.getTenantId()); | |||||
| msgQ.setType(EnumTemplateType.VERIFY_FAIL.getCode()); | |||||
| List<WxTemplateMsg> list = wxTemplateMsgMapper.select(msgQ); | |||||
| if (list.size() > 0) { | |||||
| msg = list.get(0); | |||||
| } | |||||
| if (msg == null) { | |||||
| logger.error("找不到模板Id"); | |||||
| throw new MallinkException(ErrorCode.TEMPLATE_NOT_FOUND); | |||||
| } | |||||
| /** | |||||
| * 核销失败 | |||||
| * 商品名称 {{keyword1.DATA}} | |||||
| * 核销时间 {{keyword2.DATA}} | |||||
| * 失败原因 {{keyword3.DATA}} | |||||
| * 备注 {{keyword4.DATA}} | |||||
| */ | |||||
| templateMessage = WxMaTemplateMessage.builder() | |||||
| .toUser(user.getOpenId()) | |||||
| .formId(payOrder.getPrepayId()) // 微信支付的formId是prepayId | |||||
| .page("pages/index/index") | |||||
| .data(Lists.newArrayList( | |||||
| new WxMaTemplateMessage.Data("keyword1", coupon.getTitle(), "#173177"), | |||||
| new WxMaTemplateMessage.Data("keyword2", dateFormat.format(new Date()), "#173177"), | |||||
| new WxMaTemplateMessage.Data("keyword3", "未知"), | |||||
| new WxMaTemplateMessage.Data("keyword4", couponDetail)) | |||||
| ) | |||||
| .templateId(msg.getTemplateId()) | |||||
| .emphasisKeyword("keyword1.DATA") | |||||
| .build(); | |||||
| } | |||||
| @Override | |||||
| public int queryPriceTotal(String tenantId, Date startTime, Date endTime) { | |||||
| return wxCouponOrderMapper.queryPriceTotal(tenantId, startTime, endTime); | |||||
| } | |||||
| //templateMessage.addData( new WxMaTemplateMessage.Data("keyword1", "339208499", "#173177")); | |||||
| try { | |||||
| wxMaService.getMsgService().sendTemplateMsg(templateMessage); | |||||
| } catch (WxErrorException e) { | |||||
| logger.error("支付通知发送失败: " + e.getMessage()); | |||||
| throw new MallinkException(ErrorCode.TEMPLATE_SEND_FAILED); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public List<CUserDateAmountVo> queryPriceTotalGroup(String tenantId, Date startTime, Date endTime) { | |||||
| return wxCouponOrderMapper.queryPriceTotalGroup(tenantId, startTime, endTime); | |||||
| } | |||||
| @Override | |||||
| public int queryPriceTotal(String tenantId, Date startTime, Date endTime) { | |||||
| return wxCouponOrderMapper.queryPriceTotal(tenantId, startTime, endTime); | |||||
| } | |||||
| } | } | ||||
| @@ -8,12 +8,10 @@ import com.simple.enums.*; | |||||
| import com.simple.mapper.WxCouponOrderMapper; | import com.simple.mapper.WxCouponOrderMapper; | ||||
| import com.simple.mapper.WxCouponSendMapper; | import com.simple.mapper.WxCouponSendMapper; | ||||
| import com.simple.service.*; | import com.simple.service.*; | ||||
| import org.apache.commons.lang.time.DateUtils; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import org.springframework.transaction.annotation.Transactional; | import org.springframework.transaction.annotation.Transactional; | ||||
| import java.util.Date; | |||||
| import java.util.List; | import java.util.List; | ||||
| @Service | @Service | ||||
| @@ -66,22 +64,22 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { | |||||
| @Override | @Override | ||||
| @Transactional | @Transactional | ||||
| public void sendCouponToUser(String tenantId, Long cUserId, EnumCouponSendType type) { | |||||
| public void sendCouponToUser(String tenantId, Long cUserId, EnumCouponSendSendType type) { | |||||
| //查询开关是否打开 | //查询开关是否打开 | ||||
| //查询停车或者核销的券 stopCarCouponSwitch verifyConponSwitch | //查询停车或者核销的券 stopCarCouponSwitch verifyConponSwitch | ||||
| WxCouponSend wxCouponSendQuery = new WxCouponSend(); | WxCouponSend wxCouponSendQuery = new WxCouponSend(); | ||||
| wxCouponSendQuery.setTenantId(tenantId); | wxCouponSendQuery.setTenantId(tenantId); | ||||
| int actionLogType = 0; | int actionLogType = 0; | ||||
| String configKey = ""; | String configKey = ""; | ||||
| if (type == EnumCouponSendType.CAR_STOP) { | |||||
| if (type == EnumCouponSendSendType.CAR_STOP) { | |||||
| //停车 | //停车 | ||||
| wxCouponSendQuery.setSendType(EnumCouponSendType.CAR_STOP.getCode()); | |||||
| wxCouponSendQuery.setSendType(EnumCouponSendSendType.CAR_STOP.getCode()); | |||||
| actionLogType = EnumCouponActionChannelType.CAR.getCode(); | actionLogType = EnumCouponActionChannelType.CAR.getCode(); | ||||
| configKey = "stopCarCouponSwitch"; | configKey = "stopCarCouponSwitch"; | ||||
| } | } | ||||
| if (type == EnumCouponSendType.COUPON_VERIFY) { | |||||
| if (type == EnumCouponSendSendType.COUPON_VERIFY) { | |||||
| //核销 | //核销 | ||||
| wxCouponSendQuery.setSendType(EnumCouponSendType.COUPON_VERIFY.getCode()); | |||||
| wxCouponSendQuery.setSendType(EnumCouponSendSendType.COUPON_VERIFY.getCode()); | |||||
| actionLogType = EnumCouponActionChannelType.VERIFY.getCode(); | actionLogType = EnumCouponActionChannelType.VERIFY.getCode(); | ||||
| configKey = "verifyConponSwitch"; | configKey = "verifyConponSwitch"; | ||||
| } else { | } else { | ||||
| @@ -4,16 +4,15 @@ import com.github.pagehelper.PageHelper; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.simple.common.ErrorCode; | import com.simple.common.ErrorCode; | ||||
| import com.simple.common.IdWorker; | import com.simple.common.IdWorker; | ||||
| 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.common.ResultData; | |||||
| import com.simple.domain.po.*; | |||||
| import com.simple.domain.vo.WxOrderCVo; | import com.simple.domain.vo.WxOrderCVo; | ||||
| import com.simple.enums.*; | import com.simple.enums.*; | ||||
| import com.simple.exception.MallinkException; | import com.simple.exception.MallinkException; | ||||
| import com.simple.mapper.*; | import com.simple.mapper.*; | ||||
| import com.simple.service.WxCUserService; | import com.simple.service.WxCUserService; | ||||
| import com.simple.service.WxOrderService; | import com.simple.service.WxOrderService; | ||||
| import com.simple.service.WxPayOrderService; | |||||
| import com.simple.utils.RedisLock; | import com.simple.utils.RedisLock; | ||||
| import org.apache.log4j.Logger; | import org.apache.log4j.Logger; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| @@ -60,6 +59,12 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| @Autowired | @Autowired | ||||
| WxCUserService wxCUserService; | WxCUserService wxCUserService; | ||||
| @Autowired | |||||
| WxPayOrderMapper wxPayOrderMapper; | |||||
| @Autowired | |||||
| WxPayOrderService wxPayOrderService; | |||||
| @Override | @Override | ||||
| public PageInfo<WxOrder> listAsPage(WxOrder record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxOrder> listAsPage(WxOrder record, Integer pageIndex, Integer pageSize) { | ||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxOrderMapper.findList(record)); | return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxOrderMapper.findList(record)); | ||||
| @@ -539,6 +544,37 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| return ret; | return ret; | ||||
| } | } | ||||
| /** | |||||
| * 微信关闭订单 | |||||
| */ | |||||
| @Override | |||||
| public ResultData orderClose(WxOrder order) { | |||||
| // 1. get c appid | |||||
| WxAppinfo appInfo = null; | |||||
| WxAppinfo appinfoQ = new WxAppinfo(); | |||||
| appinfoQ.setTenantId(order.getTenantId()); | |||||
| appinfoQ.setType(EnumAppType.C.getCode()); | |||||
| List<WxAppinfo> appList = wxAppinfoMapper.select(appinfoQ); | |||||
| if (appList.size() > 0) { | |||||
| appInfo = appList.get(0); | |||||
| } | |||||
| // 2. get pay order | |||||
| WxPayOrder payOrderQ = new WxPayOrder(); | |||||
| payOrderQ.setTenantId(order.getTenantId()); | |||||
| payOrderQ.setPayOrderStatus(EnumPayStatus.PAY_WAY_WAIT.getCode()); | |||||
| List<WxPayOrder> payOrders = wxPayOrderMapper.select(payOrderQ); | |||||
| for(WxPayOrder payOrder: payOrders) { | |||||
| // 3. wx pay order close | |||||
| try { | |||||
| ResultData payclose = wxPayOrderService.payOrderClose(appInfo, payOrder); | |||||
| } catch (Exception e) { | |||||
| logger.error("微信关单失败:" + e.getMessage()); | |||||
| } | |||||
| } | |||||
| return new ResultData(); | |||||
| } | |||||
| @Override | @Override | ||||
| public WxOrder getById(Long id) { | public WxOrder getById(Long id) { | ||||
| return wxOrderMapper.selectByPrimaryKey(id); | return wxOrderMapper.selectByPrimaryKey(id); | ||||
| @@ -493,8 +493,9 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * 微信关闭订单 | |||||
| * 微信关闭支付订单 | |||||
| */ | */ | ||||
| @Override | @Override | ||||
| public ResultData payOrderClose(WxAppinfo appInfo, WxPayOrder record) { | public ResultData payOrderClose(WxAppinfo appInfo, WxPayOrder record) { | ||||
| @@ -519,12 +520,18 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | Map<String, String> returnMap = WxPayment.xmlToMap(response); | ||||
| String result_code = returnMap.get("result_code"); | String result_code = returnMap.get("result_code"); | ||||
| if ("SUCCESS".equals(result_code)) { | if ("SUCCESS".equals(result_code)) { | ||||
| record.setPayOrderStatus(EnumPayStatus.PAY_WAY_FAIL.getCode()); | |||||
| record.setPayOrderStatus(EnumPayStatus.PAY_WAY_CANCEL.getCode()); | |||||
| handlePayOrderStatusUpdate(record); | handlePayOrderStatusUpdate(record); | ||||
| return new ResultData(Result.SUCCESS, "订单关闭成功", returnMap); | return new ResultData(Result.SUCCESS, "订单关闭成功", returnMap); | ||||
| } else { | } else { | ||||
| String errMsg = ""; | |||||
| JSONObject errObj = errorMapClose.getJSONObject(result_code); | JSONObject errObj = errorMapClose.getJSONObject(result_code); | ||||
| record.setFailReason(errObj.toJSONString()); | |||||
| if (errObj != null) { | |||||
| errMsg = errObj.toJSONString(); | |||||
| } else { | |||||
| errMsg = returnMap.get("return_msg"); | |||||
| } | |||||
| record.setFailReason(errMsg); | |||||
| record.setUpdateTime(new Date()); | record.setUpdateTime(new Date()); | ||||
| try { | try { | ||||
| wxPayOrderMapper.updateByPrimaryKeySelective(record); | wxPayOrderMapper.updateByPrimaryKeySelective(record); | ||||
| @@ -561,12 +568,18 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | Map<String, String> returnMap = WxPayment.xmlToMap(response); | ||||
| String result_code = returnMap.get("result_code"); | String result_code = returnMap.get("result_code"); | ||||
| if ("SUCCESS".equals(result_code)) { | if ("SUCCESS".equals(result_code)) { | ||||
| record.setPayOrderStatus(EnumPayStatus.PAY_WAY_FAIL.getCode()); | |||||
| record.setPayOrderStatus(EnumPayStatus.PAY_WAY_CANCEL.getCode()); | |||||
| handlePayOrderStatusUpdate(record); | handlePayOrderStatusUpdate(record); | ||||
| return new ResultData(Result.SUCCESS, "订单关闭成功", returnMap); | return new ResultData(Result.SUCCESS, "订单关闭成功", returnMap); | ||||
| } else { | } else { | ||||
| String errMsg = ""; | |||||
| JSONObject errObj = errorMapClose.getJSONObject(result_code); | JSONObject errObj = errorMapClose.getJSONObject(result_code); | ||||
| record.setFailReason(errObj.toJSONString()); | |||||
| if (errObj != null) { | |||||
| errMsg = errObj.toJSONString(); | |||||
| } else { | |||||
| errMsg = returnMap.get("return_msg"); | |||||
| } | |||||
| record.setFailReason(errMsg); | |||||
| record.setUpdateTime(new Date()); | record.setUpdateTime(new Date()); | ||||
| try { | try { | ||||
| wxPayOrderMapper.updateByPrimaryKeySelective(record); | wxPayOrderMapper.updateByPrimaryKeySelective(record); | ||||
| @@ -574,7 +587,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| logger.error("pay order update error: " + record.toString()); | logger.error("pay order update error: " + record.toString()); | ||||
| throw new MallinkException(ErrorCode.DB_FAIL); | throw new MallinkException(ErrorCode.DB_FAIL); | ||||
| } | } | ||||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), errObj.toJSONString(), returnMap); | |||||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), errMsg, returnMap); | |||||
| } | } | ||||
| } catch (RuntimeException e) { | } catch (RuntimeException e) { | ||||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | ||||
| @@ -755,24 +768,6 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "订单数据库更新失败: " + e.getMessage()); | throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "订单数据库更新失败: " + e.getMessage()); | ||||
| } | } | ||||
| // 微信模板通知用户 | |||||
| /* | |||||
| try { | |||||
| WxAppinfo appinfoQ = new WxAppinfo(); | |||||
| appinfoQ.setTenantId(order.getTenantId()); | |||||
| appinfoQ.setType(EnumAppType.C.getCode()); | |||||
| List<WxAppinfo> appinfoList = wxAppinfoMapper.select(appinfoQ); | |||||
| if (appinfoList.size() >0) { | |||||
| WxAppinfo appinfo = appinfoList.get(0); | |||||
| sendPaySuccessMsg(appinfo, order, updateOrder); | |||||
| } | |||||
| } catch (Exception e) { | |||||
| logger.error("微信模板通知error: " + e.getMessage()); | |||||
| // throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "订单数据库更新失败: " + e.getMessage()); | |||||
| } | |||||
| */ | |||||
| // End of 微信模板通知用户 | |||||
| /* | /* | ||||
| Map<String, String> msgMap = new HashMap<>(); | Map<String, String> msgMap = new HashMap<>(); | ||||
| try { | try { | ||||
| @@ -825,6 +820,28 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| logger.error(e.getMessage()); | logger.error(e.getMessage()); | ||||
| throw new MallinkException(ErrorCode.DB_FAIL); | throw new MallinkException(ErrorCode.DB_FAIL); | ||||
| } | } | ||||
| if (record.getPayOrderStatus() == EnumPayStatus.PAY_WAY_CANCEL.getCode()) { | |||||
| // 支付订单取消 | |||||
| if (record.getPayAmount() > 0) { | |||||
| // 1. get appinfo | |||||
| WxAppinfo appInfo = null; | |||||
| WxAppinfo appinfoQ = new WxAppinfo(); | |||||
| appinfoQ.setTenantId(order.getTenantId()); | |||||
| appinfoQ.setType(EnumAppType.C.getCode()); | |||||
| List<WxAppinfo> appList = wxAppinfoMapper.select(appinfoQ); | |||||
| if (appList.size() > 0) { | |||||
| appInfo = appList.get(0); | |||||
| } | |||||
| WxPayOrder payOrderQ = new WxPayOrder(); | |||||
| payOrderQ.setTenantId(order.getTenantId()); | |||||
| payOrderQ.setPayOrderStatus(EnumPayStatus.PAY_WAY_WAIT.getCode()); | |||||
| List<WxPayOrder> payOrders = wxPayOrderMapper.select(payOrderQ); | |||||
| for(WxPayOrder payOrder: payOrders) { | |||||
| payOrderClose(appInfo, payOrder); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | } | ||||
| // 修改订单状态 | // 修改订单状态 | ||||
| @@ -901,100 +918,8 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| wxPayOrderMapper.deleteByPrimaryKey(id); | wxPayOrderMapper.deleteByPrimaryKey(id); | ||||
| } | } | ||||
| @Override | |||||
| public void sendPaySuccess() { | |||||
| /* | |||||
| WxAppinfo appinfoQ = new WxAppinfo(); | |||||
| appinfoQ.setTenantId("234"); | |||||
| appinfoQ.setType(EnumAppType.C.getCode()); | |||||
| List<WxAppinfo> appinfoList= wxAppinfoMapper.select(appinfoQ); | |||||
| WxAppinfo appinfo = appinfoList.get(0); | |||||
| String payOrderIdStr = "196936823522459648"; | |||||
| Long payOrderId = Long.valueOf(payOrderIdStr); | |||||
| WxPayOrder updateOrder = wxPayOrderMapper.selectByPrimaryKey(payOrderId); | |||||
| WxOrder order = wxOrderMapper.selectByPrimaryKey(updateOrder.getOrderId()); | |||||
| sendPaySuccessMsg(appinfo, order, updateOrder); | |||||
| */ | |||||
| } | |||||
| /** | |||||
| * 微信模板通知用户 | |||||
| * @param updateOrder | |||||
| * 支付时间 {{keyword1.DATA}} | |||||
| * 支付方式 {{keyword2.DATA}} | |||||
| * 支付金额 {{keyword3.DATA}} | |||||
| * 商品名称 {{keyword4.DATA}} | |||||
| * 商家名称 {{keyword5.DATA}} | |||||
| * 订单状态 {{keyword6.DATA}} | |||||
| */ | |||||
| private void sendPaySuccessMsg(WxAppinfo appInfo, WxOrder order, WxPayOrder updateOrder) { | |||||
| // 1. get template id | |||||
| WxTemplateMsg msgQ = new WxTemplateMsg(); | |||||
| msgQ.setTenantId(order.getTenantId()); | |||||
| msgQ.setType(EnumTemplateType.PAY_SUCCESS.getCode()); | |||||
| WxTemplateMsg msg = null; | |||||
| List<WxTemplateMsg> list= wxTemplateMsgMapper.select(msgQ); | |||||
| if (list.size() > 0) { | |||||
| msg = list.get(0); | |||||
| } | |||||
| if (msg == null) { | |||||
| logger.error("找不到模板Id"); | |||||
| throw new MallinkException(ErrorCode.TEMPLATE_NOT_FOUND); | |||||
| } | |||||
| // 2. get coupon info | |||||
| WxCoupon coupon = wxCouponMapper.selectByPrimaryKey(order.getCouponId()); | |||||
| if (coupon == null) { | |||||
| logger.error("找不到券信息"); | |||||
| throw new MallinkException(ErrorCode.COUPON_IS_EMPTY); | |||||
| } | |||||
| // 3. merchant info | |||||
| WxMerchant merchant = wxMerchantMapper.selectByPrimaryKey(order.getMerchantId()); | |||||
| if (merchant == null) { | |||||
| logger.error("找不到商户信息"); | |||||
| throw new MallinkException(ErrorCode.MERCHANT_INFO_NOT_FOUND); | |||||
| } | |||||
| // 3. get user info | |||||
| WxCUser user = wxCUserMapper.selectByPrimaryKey(order.getCUserId()); | |||||
| if (user == null) { | |||||
| logger.error("找不到C端用户"); | |||||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | |||||
| } | |||||
| if (StringUtils.isBlank(updateOrder.getPrepayId())) { | |||||
| logger.error("prepayId为空"); | |||||
| throw new MallinkException(ErrorCode.PREPAY_ID_IS_EMPTY); | |||||
| } | |||||
| WxMaService wxMaService = MaUtil.getWeappService(appInfo); | |||||
| SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); | |||||
| WxMaTemplateMessage templateMessage = WxMaTemplateMessage.builder() | |||||
| .toUser(user.getOpenId()) | |||||
| .formId(updateOrder.getPrepayId()) // 微信支付的formId是prepayId | |||||
| .page("pages/index/index") | |||||
| .data(Lists.newArrayList( | |||||
| new WxMaTemplateMessage.Data("keyword1", dateFormat.format(new Date()), "#173177"), | |||||
| new WxMaTemplateMessage.Data("keyword2", "微信支付", "#173177"), | |||||
| new WxMaTemplateMessage.Data("keyword3", String.valueOf(updateOrder.getPayAmount()*1.0/100) + "元", "#173177"), | |||||
| new WxMaTemplateMessage.Data("keyword4", coupon.getTitle(), "#173177"), | |||||
| new WxMaTemplateMessage.Data("keyword5", merchant.getName(), "#173177"), | |||||
| new WxMaTemplateMessage.Data("keyword6", EnumOrderStatus.getEnum(order.getOrderStatus()).getMessage(), "#173177"))) | |||||
| .templateId(msg.getTemplateId()) | |||||
| .emphasisKeyword("keyword1.DATA") | |||||
| .build(); | |||||
| //templateMessage.addData( new WxMaTemplateMessage.Data("keyword1", "339208499", "#173177")); | |||||
| try { | |||||
| wxMaService.getMsgService().sendTemplateMsg(templateMessage); | |||||
| } catch (WxErrorException e) { | |||||
| logger.error("支付通知发送失败: " + e.getMessage()); | |||||
| throw new MallinkException(ErrorCode.TEMPLATE_SEND_FAILED); | |||||
| } | |||||
| } | |||||
| public static void main(String [] args) { | public static void main(String [] args) { | ||||
| Integer v = 500; | |||||
| Integer v = 50; | |||||
| Integer rate = 6; | Integer rate = 6; | ||||
| Double dChargeFee = Math.ceil(v*1.0D*6/1000); | Double dChargeFee = Math.ceil(v*1.0D*6/1000); | ||||
| Integer share_amount = v - dChargeFee.intValue(); | Integer share_amount = v - dChargeFee.intValue(); | ||||
| @@ -12,10 +12,12 @@ | |||||
| <result column="status" jdbcType="INTEGER" property="status" /> | <result column="status" jdbcType="INTEGER" property="status" /> | ||||
| <result column="is_admin" jdbcType="INTEGER" property="isAdmin" /> | <result column="is_admin" jdbcType="INTEGER" property="isAdmin" /> | ||||
| <result column="nick_name" jdbcType="VARCHAR" property="nickName" /> | <result column="nick_name" jdbcType="VARCHAR" property="nickName" /> | ||||
| <result column="phone" jdbcType="VARCHAR" property="phone" /> | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`,`tenant_id`,`username`,`name`,`password`,`create_time`,`last_login_time`,`status`,`is_admin`,`nick_name` | |||||
| `id`,`tenant_id`,`username`,`name`,`password`,`create_time`,`last_login_time`,`status`,`is_admin`,`nick_name`,`phone` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| @@ -69,7 +71,10 @@ | |||||
| <if test=" null != isAdmin "> | <if test=" null != isAdmin "> | ||||
| and `is_admin` = #{isAdmin} | and `is_admin` = #{isAdmin} | ||||
| </if> | |||||
| </if> | |||||
| <if test=" null != phone "> | |||||
| and `phone` = #{phone} | |||||
| </if> | |||||
| <if test=" null != ids "> | <if test=" null != ids "> | ||||
| and id in | and id in | ||||
| @@ -98,5 +103,17 @@ | |||||
| AND p.permission = #{permission} | AND p.permission = #{permission} | ||||
| </select> | </select> | ||||
| <select id="cntByUserName" resultType="java.lang.Long"> | |||||
| select count(*) from mall_user_info where 1=1 | |||||
| <if test=" null != username "> | |||||
| and username=#{username} | |||||
| </if> | |||||
| <if test=" null != phone "> | |||||
| and `phone` = #{phone} | |||||
| </if> | |||||
| <if test=" null != id "> | |||||
| and `id` != #{id} | |||||
| </if> | |||||
| </select> | |||||
| </mapper> | </mapper> | ||||
| @@ -136,5 +136,21 @@ | |||||
| and birthdate <= #{birthEndTime} | and birthdate <= #{birthEndTime} | ||||
| </if> | </if> | ||||
| </select> | </select> | ||||
| <select id="findCount" parameterType="com.simple.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long"> | |||||
| select count(id) from wx_c_user_basic_info where 1=1 | |||||
| <if test=" null != sex "> | |||||
| and gender =#{sex} | |||||
| </if> | |||||
| <if test=" null != startTime "> | |||||
| and create_date >= #{startTime} | |||||
| </if> | |||||
| <if test=" null != endTime"> | |||||
| and create_date < #{endTime} | |||||
| </if> | |||||
| <if test="null != tenantId"> | |||||
| and tenant_id =#{tenantId} | |||||
| </if> | |||||
| </select> | |||||
| </mapper> | </mapper> | ||||
| @@ -36,7 +36,7 @@ | |||||
| </if> | </if> | ||||
| <if test=" null != tenantId "> | <if test=" null != tenantId "> | ||||
| and `tenant_id` like concat('%', #{tenantId},'%') | |||||
| and `tenant_id` = #{tenantId} | |||||
| </if> | </if> | ||||