dev # Conflicts: # mallinkSysAdmin/src/main/java/com/iformall/controller/sys/DataInitController.javarelease_toaliyun_real
| @@ -15,8 +15,8 @@ import com.iformall.enums.EnumRentContractAppStatus; | |||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.mapper.WxCouponMapper; | import com.iformall.mapper.WxCouponMapper; | ||||
| import com.iformall.service.*; | import com.iformall.service.*; | ||||
| import com.iformall.utils.ETCPUtil; | |||||
| import com.iformall.utils.TJDCarUtil; | |||||
| import com.iformall.utils.car.ETCPUtil; | |||||
| import com.iformall.utils.car.TJDUtil; | |||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| import io.swagger.annotations.ApiImplicitParams; | import io.swagger.annotations.ApiImplicitParams; | ||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| @@ -37,7 +37,7 @@ public class WxCarController extends BaseController { | |||||
| ETCPUtil etcp = new ETCPUtil(); | ETCPUtil etcp = new ETCPUtil(); | ||||
| TJDCarUtil tjd = new TJDCarUtil(); | |||||
| TJDUtil tjd = new TJDUtil(); | |||||
| @Autowired | @Autowired | ||||
| WxParkService wxParkService; | WxParkService wxParkService; | ||||
| @@ -8,9 +8,11 @@ import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | import com.iformall.controller.base.BaseController; | ||||
| import com.iformall.domain.po.WxCoupon; | import com.iformall.domain.po.WxCoupon; | ||||
| import com.iformall.domain.po.WxCouponChannel; | import com.iformall.domain.po.WxCouponChannel; | ||||
| import com.iformall.domain.po.WxCouponPassword; | |||||
| import com.iformall.domain.vo.WxCouponStatisVo; | import com.iformall.domain.vo.WxCouponStatisVo; | ||||
| import com.iformall.enums.*; | import com.iformall.enums.*; | ||||
| import com.iformall.mapper.WxCouponChannelMapper; | import com.iformall.mapper.WxCouponChannelMapper; | ||||
| import com.iformall.service.WxCouponPasswordService; | |||||
| import com.iformall.service.WxCouponService; | import com.iformall.service.WxCouponService; | ||||
| import com.iformall.service.WxFlowService; | import com.iformall.service.WxFlowService; | ||||
| import com.iformall.utils.DateUtils; | import com.iformall.utils.DateUtils; | ||||
| @@ -24,6 +26,9 @@ 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.web.bind.annotation.*; | import org.springframework.web.bind.annotation.*; | ||||
| import javax.servlet.http.HttpServletRequest; | |||||
| import javax.servlet.http.HttpServletResponse; | |||||
| import java.util.*; | import java.util.*; | ||||
| @RestController | @RestController | ||||
| @@ -35,6 +40,8 @@ public class WxCouponController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| private WxCouponService wxCouponService; | private WxCouponService wxCouponService; | ||||
| @Autowired | @Autowired | ||||
| private WxCouponPasswordService couponPasswordService; | |||||
| @Autowired | |||||
| private WxCouponChannelMapper wxCouponChannelMapper; | private WxCouponChannelMapper wxCouponChannelMapper; | ||||
| @Autowired | @Autowired | ||||
| private WxFlowService wxFlowService; | private WxFlowService wxFlowService; | ||||
| @@ -51,6 +58,7 @@ public class WxCouponController extends BaseController { | |||||
| wxCoupon.setTenantId(getTenantId()); | wxCoupon.setTenantId(getTenantId()); | ||||
| return wxCouponService.list(wxCoupon, pageNum, pageSize); //全列表 | return wxCouponService.list(wxCoupon, pageNum, pageSize); //全列表 | ||||
| } | } | ||||
| @ApiOperation("分页列表接口") | @ApiOperation("分页列表接口") | ||||
| @GetMapping("listWithTypePress") | @GetMapping("listWithTypePress") | ||||
| @ApiImplicitParams({ | @ApiImplicitParams({ | ||||
| @@ -79,15 +87,16 @@ public class WxCouponController extends BaseController { | |||||
| @SystemControllerLog(description = "券投放-新增") | @SystemControllerLog(description = "券投放-新增") | ||||
| public ResultData add(@RequestBody WxCoupon wxCoupon) { | public ResultData add(@RequestBody WxCoupon wxCoupon) { | ||||
| logger.debug("[" + getIpAddr() + "] WxCouponController::add"); | logger.debug("[" + getIpAddr() + "] WxCouponController::add"); | ||||
| wxCoupon.setTenantId(getTenantId()); | |||||
| ResultData resultData = wxCouponService.saveOrUpdate(wxCoupon); | ResultData resultData = wxCouponService.saveOrUpdate(wxCoupon); | ||||
| if(resultData.code != 200){ | |||||
| if (resultData.code != 200) { | |||||
| return resultData; | return resultData; | ||||
| } | } | ||||
| //启动投放审批 | //启动投放审批 | ||||
| if(wxCoupon.getFlowParams() !=null && wxCoupon.getFlowParams().size()>0) { | |||||
| wxCoupon.getFlowParams().put("businessId",wxCoupon.getId()); | |||||
| if (wxCoupon.getFlowParams() != null && wxCoupon.getFlowParams().size() > 0) { | |||||
| wxCoupon.getFlowParams().put("businessId", wxCoupon.getId()); | |||||
| wxFlowService.start(wxCoupon.getFlowParams(), getUserId(), getUser().getName(), getTenantId()); | wxFlowService.start(wxCoupon.getFlowParams(), getUserId(), getUser().getName(), getTenantId()); | ||||
| //修改coupon applyStatus状态为审核中 | //修改coupon applyStatus状态为审核中 | ||||
| wxCoupon.setPutApplyStatus(EnumRentContractAppStatus.APPLYING.getCode()); | wxCoupon.setPutApplyStatus(EnumRentContractAppStatus.APPLYING.getCode()); | ||||
| @@ -103,12 +112,12 @@ public class WxCouponController extends BaseController { | |||||
| if (wxCoupon.getId() == null) { | if (wxCoupon.getId() == null) { | ||||
| return new ResultData(ResultData.ERROR, "缺少id"); | return new ResultData(ResultData.ERROR, "缺少id"); | ||||
| } | } | ||||
| if(EnumDelFlag.YES.getCode().equals(wxCoupon.getIsDel())){ | |||||
| if (EnumDelFlag.YES.getCode().equals(wxCoupon.getIsDel())) { | |||||
| WxCouponChannel query = new WxCouponChannel(); | WxCouponChannel query = new WxCouponChannel(); | ||||
| query.setTenantId(wxCoupon.getTenantId()); | query.setTenantId(wxCoupon.getTenantId()); | ||||
| query.setCouponId(wxCoupon.getId()); | query.setCouponId(wxCoupon.getId()); | ||||
| query.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); | query.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); | ||||
| if(CollectionUtils.isNotEmpty(wxCouponChannelMapper.findList(query))){ | |||||
| if (CollectionUtils.isNotEmpty(wxCouponChannelMapper.findList(query))) { | |||||
| return new ResultData(ResultData.ERROR, "有活动正在上架,请先下架。"); | return new ResultData(ResultData.ERROR, "有活动正在上架,请先下架。"); | ||||
| } | } | ||||
| } | } | ||||
| @@ -116,14 +125,14 @@ public class WxCouponController extends BaseController { | |||||
| //启动审批流 | //启动审批流 | ||||
| if (wxCoupon.getFlowParams() != null && wxCoupon.getFlowParams().size() > 0) { | if (wxCoupon.getFlowParams() != null && wxCoupon.getFlowParams().size() > 0) { | ||||
| logger.info("------coupon.update().businessType:"+wxCoupon.getFlowParams().get("businessType")); | |||||
| wxCoupon.getFlowParams().put("businessId",wxCoupon.getId()); | |||||
| logger.info("------coupon.update().businessType:" + wxCoupon.getFlowParams().get("businessType")); | |||||
| wxCoupon.getFlowParams().put("businessId", wxCoupon.getId()); | |||||
| wxFlowService.start(wxCoupon.getFlowParams(), getUserId(), getUser().getName(), getTenantId()); | wxFlowService.start(wxCoupon.getFlowParams(), getUserId(), getUser().getName(), getTenantId()); | ||||
| //作废审批 | //作废审批 | ||||
| if (EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode().equals(wxCoupon.getStatus())) { | if (EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode().equals(wxCoupon.getStatus())) { | ||||
| wxCoupon.setCancleApplyStatus(EnumRentContractAppStatus.APPLYING.getCode()); | wxCoupon.setCancleApplyStatus(EnumRentContractAppStatus.APPLYING.getCode()); | ||||
| return new ResultData(wxCoupon); | return new ResultData(wxCoupon); | ||||
| }else{ | |||||
| } else { | |||||
| //投放审批 | //投放审批 | ||||
| wxCoupon.setPutApplyStatus(EnumRentContractAppStatus.APPLYING.getCode()); | wxCoupon.setPutApplyStatus(EnumRentContractAppStatus.APPLYING.getCode()); | ||||
| } | } | ||||
| @@ -132,7 +141,7 @@ public class WxCouponController extends BaseController { | |||||
| } | } | ||||
| @ApiOperation("根据id更新库存及有效期接口") | @ApiOperation("根据id更新库存及有效期接口") | ||||
| @PostMapping("updateStokeAndValidDate") | |||||
| @PostMapping("updateStokeAndValidDate") | |||||
| @SystemControllerLog(description = "券投放-库存/有效期更新") | @SystemControllerLog(description = "券投放-库存/有效期更新") | ||||
| public ResultData updateStokeAndValidDate(@RequestBody WxCoupon wxCoupon) { | public ResultData updateStokeAndValidDate(@RequestBody WxCoupon wxCoupon) { | ||||
| logger.debug("[" + getIpAddr() + "] WxCouponController::updateStokeAndValidDate"); | logger.debug("[" + getIpAddr() + "] WxCouponController::updateStokeAndValidDate"); | ||||
| @@ -140,93 +149,93 @@ public class WxCouponController extends BaseController { | |||||
| logger.error("缺少id"); | logger.error("缺少id"); | ||||
| return new ResultData(ResultData.ERROR, "缺少id"); | return new ResultData(ResultData.ERROR, "缺少id"); | ||||
| } | } | ||||
| if(wxCoupon.getType() == null) { | |||||
| if (wxCoupon.getType() == null) { | |||||
| logger.error("缺少type"); | logger.error("缺少type"); | ||||
| return new ResultData(ResultData.ERROR, "缺少type"); | return new ResultData(ResultData.ERROR, "缺少type"); | ||||
| } | } | ||||
| if(wxCoupon.getRemainInventory() == null || wxCoupon.getInventory() == null) { | |||||
| if (wxCoupon.getRemainInventory() == null || wxCoupon.getInventory() == null) { | |||||
| logger.error("库存错误1"); | logger.error("库存错误1"); | ||||
| return new ResultData(ErrorCode.COUPON_STOCK_ERR); | return new ResultData(ErrorCode.COUPON_STOCK_ERR); | ||||
| } | } | ||||
| if(wxCoupon.getRemainInventory() > wxCoupon.getInventory()) { | |||||
| if (wxCoupon.getRemainInventory() > wxCoupon.getInventory()) { | |||||
| logger.error("库存错误2"); | logger.error("库存错误2"); | ||||
| return new ResultData(ErrorCode.COUPON_STOCK_ERR); | return new ResultData(ErrorCode.COUPON_STOCK_ERR); | ||||
| } | } | ||||
| if(wxCoupon.getValidType() == null) { | |||||
| if (wxCoupon.getValidType() == null) { | |||||
| logger.error("库存错误3"); | logger.error("库存错误3"); | ||||
| return new ResultData(ErrorCode.COUPON_VALID_DATE_ERR); | return new ResultData(ErrorCode.COUPON_VALID_DATE_ERR); | ||||
| } | } | ||||
| if(wxCoupon.getValidType().equals(EnumCouponValidType.BETWEEN_TWO_TIME.getCode())) { | |||||
| if(wxCoupon.getValidEndDate() == null) { | |||||
| if (wxCoupon.getValidType().equals(EnumCouponValidType.BETWEEN_TWO_TIME.getCode())) { | |||||
| if (wxCoupon.getValidEndDate() == null) { | |||||
| logger.error("有效期错误1"); | logger.error("有效期错误1"); | ||||
| return new ResultData(ErrorCode.COUPON_VALID_DATE_ERR); | return new ResultData(ErrorCode.COUPON_VALID_DATE_ERR); | ||||
| } | } | ||||
| } else { | } else { | ||||
| if(wxCoupon.getValidDays() == null) { | |||||
| if (wxCoupon.getValidDays() == null) { | |||||
| logger.error("有效期错误2"); | logger.error("有效期错误2"); | ||||
| return new ResultData(ErrorCode.COUPON_VALID_DATE_ERR); | return new ResultData(ErrorCode.COUPON_VALID_DATE_ERR); | ||||
| } | } | ||||
| } | } | ||||
| if(wxCoupon.getType().equals(EnumCouponType.COUPON_TINGCHE.getCode()) || | |||||
| wxCoupon.getType().equals(EnumCouponType.COUPON_CREDIT_PARK.getCode())) { | |||||
| if (wxCoupon.getType().equals(EnumCouponType.COUPON_TINGCHE.getCode()) || | |||||
| wxCoupon.getType().equals(EnumCouponType.COUPON_CREDIT_PARK.getCode())) { | |||||
| logger.error("券库存有效期不支持停车券"); | logger.error("券库存有效期不支持停车券"); | ||||
| return new ResultData(ErrorCode.COUPON_STOCK_DATE_NO_CAR); | return new ResultData(ErrorCode.COUPON_STOCK_DATE_NO_CAR); | ||||
| } | } | ||||
| wxCoupon.setTenantId(getTenantId()); | wxCoupon.setTenantId(getTenantId()); | ||||
| WxCoupon coupon = wxCouponService.findById(wxCoupon); | WxCoupon coupon = wxCouponService.findById(wxCoupon); | ||||
| if(coupon!=null){ | |||||
| if((wxCoupon.getValidEndDate()!=null&&coupon.getValidEndDate()!=null && DateUtils.format(wxCoupon.getValidEndDate()).equals(DateUtils.format(coupon.getValidEndDate())) | |||||
| if (coupon != null) { | |||||
| if ((wxCoupon.getValidEndDate() != null && coupon.getValidEndDate() != null && DateUtils.format(wxCoupon.getValidEndDate()).equals(DateUtils.format(coupon.getValidEndDate())) | |||||
| && wxCoupon.getInventory().equals(coupon.getInventory())) | && wxCoupon.getInventory().equals(coupon.getInventory())) | ||||
| || | || | ||||
| (wxCoupon.getValidDays()!=null && coupon.getValidDays()!=null && wxCoupon.getInventory().equals(coupon.getInventory()) && | |||||
| (wxCoupon.getValidDays() != null && coupon.getValidDays() != null && wxCoupon.getInventory().equals(coupon.getInventory()) && | |||||
| wxCoupon.getValidDays().equals(coupon.getValidDays())) | wxCoupon.getValidDays().equals(coupon.getValidDays())) | ||||
| ){ | |||||
| ) { | |||||
| return new ResultData(ErrorCode.COUPON_STOCK_VALID_DATE_SETTING_ERR); | return new ResultData(ErrorCode.COUPON_STOCK_VALID_DATE_SETTING_ERR); | ||||
| } | } | ||||
| if(wxCoupon.getValidEndDate()!=null && wxCoupon.getValidEndDate().before(coupon.getValidEndDate())){ | |||||
| if (wxCoupon.getValidEndDate() != null && wxCoupon.getValidEndDate().before(coupon.getValidEndDate())) { | |||||
| return new ResultData(ErrorCode.COUPON_STOCK_ENDTIME_ERR); | return new ResultData(ErrorCode.COUPON_STOCK_ENDTIME_ERR); | ||||
| } | } | ||||
| if(wxCoupon.getInventory()!=null && wxCoupon.getInventory().intValue() < coupon.getInventory().intValue() ){ | |||||
| if (wxCoupon.getInventory() != null && wxCoupon.getInventory().intValue() < coupon.getInventory().intValue()) { | |||||
| return new ResultData(ErrorCode.COUPON_STOCK_INV_ERR); | return new ResultData(ErrorCode.COUPON_STOCK_INV_ERR); | ||||
| } | } | ||||
| if(wxCoupon.getValidDays()!=null && coupon.getValidDays()!=null && wxCoupon.getValidDays().intValue() < coupon.getValidDays().intValue()){ | |||||
| if (wxCoupon.getValidDays() != null && coupon.getValidDays() != null && wxCoupon.getValidDays().intValue() < coupon.getValidDays().intValue()) { | |||||
| return new ResultData(ErrorCode.COUPON_STOCK_ENDTIME_ERR); | return new ResultData(ErrorCode.COUPON_STOCK_ENDTIME_ERR); | ||||
| } | } | ||||
| } | } | ||||
| //启动审批流 | //启动审批流 | ||||
| if(wxCoupon.getFlowParams() != null && wxCoupon.getFlowParams().size() >0){ | |||||
| List<Map<String,Object>> variables = (List)wxCoupon.getFlowParams().get("variables"); | |||||
| Map<String,Object> map = new HashedMap(); | |||||
| map.put("key","inventory"); | |||||
| map.put("value",wxCoupon.getInventory()); | |||||
| if (wxCoupon.getFlowParams() != null && wxCoupon.getFlowParams().size() > 0) { | |||||
| List<Map<String, Object>> variables = (List) wxCoupon.getFlowParams().get("variables"); | |||||
| Map<String, Object> map = new HashedMap(); | |||||
| map.put("key", "inventory"); | |||||
| map.put("value", wxCoupon.getInventory()); | |||||
| variables.add(map); | variables.add(map); | ||||
| map = new HashedMap(); | map = new HashedMap(); | ||||
| map.put("key","remainInventory"); | |||||
| map.put("value",wxCoupon.getRemainInventory()); | |||||
| map.put("key", "remainInventory"); | |||||
| map.put("value", wxCoupon.getRemainInventory()); | |||||
| variables.add(map); | variables.add(map); | ||||
| map = new HashedMap(); | map = new HashedMap(); | ||||
| map.put("key","type"); | |||||
| map.put("value",wxCoupon.getType()); | |||||
| map.put("key", "type"); | |||||
| map.put("value", wxCoupon.getType()); | |||||
| variables.add(map); | variables.add(map); | ||||
| map = new HashedMap(); | map = new HashedMap(); | ||||
| map.put("key","validEndDate"); | |||||
| map.put("value",wxCoupon.getValidEndDate()); | |||||
| map.put("key", "validEndDate"); | |||||
| map.put("value", wxCoupon.getValidEndDate()); | |||||
| map = new HashedMap(); | map = new HashedMap(); | ||||
| map.put("key","validStartDate"); | |||||
| map.put("value",wxCoupon.getValidStartDate()); | |||||
| map.put("key", "validStartDate"); | |||||
| map.put("value", wxCoupon.getValidStartDate()); | |||||
| map = new HashedMap(); | map = new HashedMap(); | ||||
| map.put("key","validType"); | |||||
| map.put("value",wxCoupon.getValidType()); | |||||
| map.put("key", "validType"); | |||||
| map.put("value", wxCoupon.getValidType()); | |||||
| variables.add(map); | variables.add(map); | ||||
| map = new HashedMap(); | map = new HashedMap(); | ||||
| map.put("key","validDays"); | |||||
| map.put("value",wxCoupon.getValidDays()); | |||||
| map.put("key", "validDays"); | |||||
| map.put("value", wxCoupon.getValidDays()); | |||||
| variables.add(map); | variables.add(map); | ||||
| wxCoupon.getFlowParams().put("businessId",wxCoupon.getId()); | |||||
| wxCoupon.getFlowParams().put("businessId", wxCoupon.getId()); | |||||
| wxFlowService.start(wxCoupon.getFlowParams(), getUserId(), getUser().getName(), getTenantId()); | wxFlowService.start(wxCoupon.getFlowParams(), getUserId(), getUser().getName(), getTenantId()); | ||||
| //更新状态 | //更新状态 | ||||
| WxCoupon updateCoupon = new WxCoupon(); | WxCoupon updateCoupon = new WxCoupon(); | ||||
| @@ -235,7 +244,7 @@ public class WxCouponController extends BaseController { | |||||
| updateCoupon.setStockApplyStatus(EnumRentContractAppStatus.APPLYING.getCode()); | updateCoupon.setStockApplyStatus(EnumRentContractAppStatus.APPLYING.getCode()); | ||||
| updateCoupon.setUpdateDate(new Date()); | updateCoupon.setUpdateDate(new Date()); | ||||
| wxCouponService.update(updateCoupon); | wxCouponService.update(updateCoupon); | ||||
| }else{ | |||||
| } else { | |||||
| return wxCouponService.updateCouponStockAndEndTime(wxCoupon); | return wxCouponService.updateCouponStockAndEndTime(wxCoupon); | ||||
| } | } | ||||
| @@ -257,7 +266,7 @@ public class WxCouponController extends BaseController { | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | ||||
| @SystemControllerLog(description = "券投放-查询") | @SystemControllerLog(description = "券投放-查询") | ||||
| public ResultData findById(@RequestParam Long id) { | public ResultData findById(@RequestParam Long id) { | ||||
| logger.debug("[" + getIpAddr() + "] WxCouponController::findById");; | |||||
| logger.debug("[" + getIpAddr() + "] WxCouponController::findById"); | |||||
| return new ResultData(wxCouponService.getVoById(id)); | return new ResultData(wxCouponService.getVoById(id)); | ||||
| } | } | ||||
| @@ -270,26 +279,26 @@ public class WxCouponController extends BaseController { | |||||
| @SystemControllerLog(description = "券投放-卡营销列表") | @SystemControllerLog(description = "券投放-卡营销列表") | ||||
| public ResultData findCardCountList(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) { | public ResultData findCardCountList(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) { | ||||
| //默认时间本月第一天,截止到当天 | //默认时间本月第一天,截止到当天 | ||||
| Map<String,Object> result = new HashedMap(); | |||||
| if(wxCoupon.getStartdate() == null){ | |||||
| Map<String, Object> result = new HashedMap(); | |||||
| if (wxCoupon.getStartdate() == null) { | |||||
| wxCoupon.setStartdate(DateUtils.getFirstDayForCurrMonth()); | wxCoupon.setStartdate(DateUtils.getFirstDayForCurrMonth()); | ||||
| } | } | ||||
| if(wxCoupon.getEnddate() == null){ | |||||
| if (wxCoupon.getEnddate() == null) { | |||||
| wxCoupon.setEnddate(DateUtils.stringToDate(DateUtils.getSystemTime("yyyy-MM-dd") + " 23:59:59")); | wxCoupon.setEnddate(DateUtils.stringToDate(DateUtils.getSystemTime("yyyy-MM-dd") + " 23:59:59")); | ||||
| } | } | ||||
| PageInfo<WxCouponStatisVo> pageInfo = wxCouponService.findCountData(wxCoupon,pageNum,pageSize); | |||||
| for (WxCouponStatisVo coupon:pageInfo.getList()) { | |||||
| if(coupon.getSaleAmount() == null){ | |||||
| PageInfo<WxCouponStatisVo> pageInfo = wxCouponService.findCountData(wxCoupon, pageNum, pageSize); | |||||
| for (WxCouponStatisVo coupon : pageInfo.getList()) { | |||||
| if (coupon.getSaleAmount() == null) { | |||||
| coupon.setSaleAmount(0); | coupon.setSaleAmount(0); | ||||
| } | } | ||||
| if(coupon.getSumPayment() == null){ | |||||
| if (coupon.getSumPayment() == null) { | |||||
| coupon.setSumPayment(0); | coupon.setSumPayment(0); | ||||
| } | } | ||||
| if(coupon.getSumSubsidy() == null){ | |||||
| if (coupon.getSumSubsidy() == null) { | |||||
| coupon.setSumSubsidy(0); | coupon.setSumSubsidy(0); | ||||
| } | } | ||||
| } | } | ||||
| result.put("list",pageInfo); | |||||
| result.put("list", pageInfo); | |||||
| return new ResultData(result); | return new ResultData(result); | ||||
| } | } | ||||
| @@ -301,20 +310,20 @@ public class WxCouponController extends BaseController { | |||||
| @SystemControllerLog(description = "券投放-券营销列表") | @SystemControllerLog(description = "券投放-券营销列表") | ||||
| public ResultData findCouponCountList(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) { | public ResultData findCouponCountList(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) { | ||||
| //默认时间本月第一天,截止到当天 | //默认时间本月第一天,截止到当天 | ||||
| Map<String,Object> result = new HashedMap(); | |||||
| if(wxCoupon.getStartdate() == null){ | |||||
| Map<String, Object> result = new HashedMap(); | |||||
| if (wxCoupon.getStartdate() == null) { | |||||
| wxCoupon.setStartdate(DateUtils.getFirstDayForCurrMonth()); | wxCoupon.setStartdate(DateUtils.getFirstDayForCurrMonth()); | ||||
| } | } | ||||
| if(wxCoupon.getEnddate() == null){ | |||||
| if (wxCoupon.getEnddate() == null) { | |||||
| wxCoupon.setEnddate(DateUtils.stringToDate(DateUtils.getSystemTime("yyyy-MM-dd") + " 23:59:59")); | wxCoupon.setEnddate(DateUtils.stringToDate(DateUtils.getSystemTime("yyyy-MM-dd") + " 23:59:59")); | ||||
| } | } | ||||
| PageInfo<WxCouponStatisVo> pageInfo = wxCouponService.findCouponData(wxCoupon,pageNum,pageSize); | |||||
| for (WxCouponStatisVo coupon:pageInfo.getList()) { | |||||
| if(coupon.getSumSubsidy() == null){ | |||||
| PageInfo<WxCouponStatisVo> pageInfo = wxCouponService.findCouponData(wxCoupon, pageNum, pageSize); | |||||
| for (WxCouponStatisVo coupon : pageInfo.getList()) { | |||||
| if (coupon.getSumSubsidy() == null) { | |||||
| coupon.setSumSubsidy(0); | coupon.setSumSubsidy(0); | ||||
| } | } | ||||
| if(coupon.getSumSubsidy() == null){ | |||||
| if (coupon.getSumSubsidy() == null) { | |||||
| coupon.setSumSubsidy(0); | coupon.setSumSubsidy(0); | ||||
| } | } | ||||
| } | } | ||||
| @@ -328,10 +337,20 @@ public class WxCouponController extends BaseController { | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | ||||
| @SystemControllerLog(description = "券投放-砍价营销列表") | @SystemControllerLog(description = "券投放-砍价营销列表") | ||||
| public ResultData findPressCountList(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) { | public ResultData findPressCountList(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) { | ||||
| Map<String,Object> result = new HashedMap(); | |||||
| Map<String, Object> result = new HashedMap(); | |||||
| wxCoupon.setTenantId(getTenantId()); | wxCoupon.setTenantId(getTenantId()); | ||||
| PageInfo<WxCouponStatisVo> pages = wxCouponService.findPressData(wxCoupon,pageNum,pageSize); | |||||
| PageInfo<WxCouponStatisVo> pages = wxCouponService.findPressData(wxCoupon, pageNum, pageSize); | |||||
| return new ResultData(pages); | return new ResultData(pages); | ||||
| } | } | ||||
| @GetMapping("exportCouponPassword") | |||||
| @SystemControllerLog(description = "卡券兑换码-导出数据") | |||||
| public void exportCouponPassword(@ModelAttribute WxCouponPassword wxCouponPassword, HttpServletRequest request, HttpServletResponse response) { | |||||
| wxCouponPassword.setTenantId(getTenantId()); | |||||
| if (wxCouponPassword.getCouponId() == null) { | |||||
| wxCouponPassword.setCouponId(0L); | |||||
| } | |||||
| couponPasswordService.exportData(request, response, wxCouponPassword); | |||||
| } | |||||
| } | } | ||||
| @@ -0,0 +1,63 @@ | |||||
| package com.iformall.controller.market; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.BaseEntity; | |||||
| import com.iformall.domain.po.WxCouponPassword; | |||||
| import com.iformall.domain.vo.WxCouponPasswordCountInfoVO; | |||||
| import com.iformall.service.WxCouponPasswordService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.GetMapping; | |||||
| import org.springframework.web.bind.annotation.ModelAttribute; | |||||
| import org.springframework.web.bind.annotation.RequestMapping; | |||||
| import org.springframework.web.bind.annotation.RestController; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| @RestController | |||||
| @RequestMapping("couponPassword") | |||||
| @Api(description = "免费卡接口") | |||||
| public class WxCouponPasswordController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxCouponPasswordService wxCouponPasswordService; | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("/list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "列表") | |||||
| public ResultData list(@ModelAttribute WxCouponPassword wxCouponPassword, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCouponPasswordController::list"); | |||||
| wxCouponPassword.setTenantId(getTenantId()); | |||||
| wxCouponPassword.setSortColumns(BaseEntity.SortField.CreateDate_DESC, BaseEntity.SortField.Id_DESC); | |||||
| final PageInfo<WxCouponPassword> page = wxCouponPasswordService.listAsPage(wxCouponPassword, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("可发送卡数据") | |||||
| @GetMapping("/findCouponList") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "可发送卡数据") | |||||
| public ResultData findCouponList(@ModelAttribute WxCouponPassword wxCouponPassword, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCouponPasswordController::findCouponList"); | |||||
| wxCouponPassword.setTenantId(getTenantId()); | |||||
| final PageInfo<WxCouponPasswordCountInfoVO> page = wxCouponPasswordService.findCouponList(wxCouponPassword, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,133 @@ | |||||
| package com.iformall.controller.market; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.*; | |||||
| import com.iformall.enums.EnumCouponPasswordStatus; | |||||
| import com.iformall.enums.EnumCouponStatus; | |||||
| import com.iformall.enums.EnumCouponValidType; | |||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.service.PushLimitService; | |||||
| import com.iformall.service.WxCouponPasswordService; | |||||
| import com.iformall.service.WxCouponPresentService; | |||||
| import com.iformall.service.WxCouponService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import java.util.Date; | |||||
| import java.util.HashSet; | |||||
| import java.util.List; | |||||
| import java.util.Set; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| @RestController | |||||
| @RequestMapping("couponPresent") | |||||
| @Api(description = "卡投放接口") | |||||
| public class WxCouponPresentController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxCouponPresentService wxCouponPresentService; | |||||
| @Autowired | |||||
| PushLimitService pushLimitService; | |||||
| @Autowired | |||||
| WxCouponService wxCouponService; | |||||
| @Autowired | |||||
| WxCouponPasswordService wxCouponPasswordService; | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("/list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "列表") | |||||
| public ResultData list(@ModelAttribute WxCouponPresent wxCouponPresent, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCouponPresentController::list"); | |||||
| wxCouponPresent.setTenantId(getTenantId()); | |||||
| wxCouponPresent.setSortColumns(BaseEntity.SortField.CreateTime_DESC, BaseEntity.SortField.Id_DESC); | |||||
| final PageInfo<WxCouponPresent> page = wxCouponPresentService.listAsPage(wxCouponPresent, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("根据id查询接口") | |||||
| @GetMapping("/findById") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "查询") | |||||
| public ResultData findById(@RequestParam Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCouponPresentController::findById"); | |||||
| return new ResultData(wxCouponPresentService.findById(id)); | |||||
| } | |||||
| @ApiOperation("新增接口") | |||||
| @PostMapping("add") | |||||
| @SystemControllerLog(description = "新增") | |||||
| public ResultData add(@RequestBody WxCouponPresent wxCouponPresent) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCouponInjectController::add"); | |||||
| if (wxCouponPresent.getCouponId() == null) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "请选择卡"); | |||||
| } | |||||
| if (wxCouponPresent.getPhones().isEmpty()) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "请填写手机号"); | |||||
| } | |||||
| MallUserInfo user = getUser(); | |||||
| wxCouponPresent.setUserId(user.getId()); | |||||
| wxCouponPresent.setTenantId(user.getTenantId()); | |||||
| try { | |||||
| pushLimitService.checkSendTime(user.getTenantId()); | |||||
| } catch (MallinkException e) { | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||||
| } | |||||
| WxCoupon wxCoupon = wxCouponService.getById(wxCouponPresent.getCouponId()); | |||||
| if (wxCoupon.getValidType().equals(EnumCouponValidType.BETWEEN_TWO_TIME.getCode())) { //时间范围 | |||||
| if (new Date().after(wxCoupon.getValidEndDate())) { | |||||
| return new ResultData(ErrorCode.COUPON_IS_EXPIRED); | |||||
| } | |||||
| } | |||||
| if (!wxCoupon.getStatus().equals(EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode())) { | |||||
| return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF); | |||||
| } | |||||
| //获取手机号 | |||||
| String phones = wxCouponPresent.getPhones(); | |||||
| String[] phoneSplit = phones.split(","); | |||||
| Set<String> phoneSet = new HashSet<>(phoneSplit.length); | |||||
| for (String phone : phoneSplit) { | |||||
| if (!phone.isEmpty()) { | |||||
| phoneSet.add(phone); | |||||
| } | |||||
| } | |||||
| //查询有效券数量 | |||||
| WxCouponPassword wxCouponPassword = new WxCouponPassword(); | |||||
| wxCouponPassword.setTenantId(user.getTenantId()); | |||||
| wxCouponPassword.setCouponId(wxCouponPresent.getCouponId()); | |||||
| wxCouponPassword.setStatus(EnumCouponPasswordStatus.INIT.getCode()); | |||||
| List<WxCouponPassword> list = wxCouponPasswordService.findList(wxCouponPassword); | |||||
| if (phoneSet.size() > list.size()) { | |||||
| logger.info(ErrorCode.REMAIN_IS_EMPTY.getMessage()); | |||||
| return new ResultData(ErrorCode.REMAIN_IS_EMPTY); | |||||
| } | |||||
| wxCouponPresent.setCouponName(wxCoupon.getTitle()); | |||||
| wxCouponPresentService.add(wxCouponPresent, list, phoneSet); | |||||
| return new ResultData(); | |||||
| } | |||||
| } | |||||
| @@ -164,7 +164,7 @@ public class WxOrderController extends BaseController { | |||||
| if (!wxOrderService.checkCouponIsFree(coupon)) | if (!wxOrderService.checkCouponIsFree(coupon)) | ||||
| return new ResultData(ErrorCode.COUPON_IS_NOT_FREE); | return new ResultData(ErrorCode.COUPON_IS_NOT_FREE); | ||||
| // 免费券 | // 免费券 | ||||
| order = wxOrderService.saveFreeOrderForCoupon(user, coupon, orderSaveDto.getCouponChannelId(), orderSaveDto.getFormId()); | |||||
| order = wxOrderService.saveFreeOrderForCoupon(user, coupon, orderSaveDto.getCouponChannelId(), orderSaveDto.getFormId(), null); | |||||
| return new ResultData(order); | return new ResultData(order); | ||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| logger.error(e.getMessage()); | logger.error(e.getMessage()); | ||||
| @@ -129,7 +129,8 @@ public class TenantInfoImpl implements TenantInfo { | |||||
| return true; | return true; | ||||
| if ("com.iformall.mapper.WxBillPropertyMapper.insertBillAction".equals(ms.getId())) | if ("com.iformall.mapper.WxBillPropertyMapper.insertBillAction".equals(ms.getId())) | ||||
| return true; | return true; | ||||
| if ("com.iformall.mapper.WxCouponPasswordMapper.updateStatus".equals(ms.getId())) | |||||
| return true; | |||||
| return false; | return false; | ||||
| } | } | ||||
| } | } | ||||
| @@ -0,0 +1,2 @@ | |||||
| ALTER TABLE `wx_card_info` | |||||
| CHANGE COLUMN `transaction_id` `transaction_id` varchar(36) COMMENT '微信订单号-购买类储值卡时的订单号'; | |||||
| @@ -0,0 +1,15 @@ | |||||
| DROP TABLE IF EXISTS wx_coupon_password; | |||||
| CREATE TABLE wx_coupon_password( | |||||
| `id` bigint(20) NOT NULL COMMENT '主键ID', | |||||
| `tenant_id` varchar(10) NOT NULL COMMENT '租户ID', | |||||
| `coupon_id` bigint(20) NOT NULL COMMENT '卡券ID', | |||||
| `coupon_short` VARCHAR(2) NULL COMMENT '券短ID', | |||||
| `password` varchar(50) NOT NULL COMMENT '商户名称', | |||||
| `status` smallint(2) NOT NULL COMMENT '卡密状态: 0初始1信息发出中2信息已发出3已使用', | |||||
| `sended_phone` varchar(20) NULL COMMENT '卡密发送到手机', | |||||
| `card_id` bigint(20) NULL COMMENT '卡包ID', | |||||
| `create_date` datetime NOT NULL COMMENT '创建时间', | |||||
| `update_date` datetime NOT NULL COMMENT '更新时间', | |||||
| `expire_date` datetime NULL COMMENT '卡密过期时间(默认发送后一个月内过期)', | |||||
| PRIMARY KEY (`id`) | |||||
| ) ENGINE=`InnoDB` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='卡券领取密码' CHECKSUM=0 DELAY_KEY_WRITE=0; | |||||
| @@ -0,0 +1,2 @@ | |||||
| ALTER TABLE `wx_coupon` | |||||
| ADD COLUMN `password_support` smallint(2) DEFAULT 0 COMMENT '是否支持卡密(0:禁用, 1支持)'; | |||||
| @@ -0,0 +1,12 @@ | |||||
| create table wx_coupon_present( | |||||
| `id` bigint(20) NOT NULL COMMENT '主键ID', | |||||
| `tenant_id` varchar(10) NOT NULL COMMENT '租户ID', | |||||
| `user_id` bigint(20) NOT NULL COMMENT '用户ID', | |||||
| `coupon_id` bigint(20) DEFAULT NULL COMMENT '券ID', | |||||
| `coupon_name` varchar(20) DEFAULT NULL COMMENT '券名称', | |||||
| `phones` text DEFAULT NULL COMMENT '手机号码', | |||||
| `create_time` datetime DEFAULT CURRENT_TIMESTAMP, | |||||
| `update_time` datetime DEFAULT CURRENT_TIMESTAMP, | |||||
| PRIMARY KEY (`id`), | |||||
| UNIQUE KEY `id_UNIQUE` (`id`) | |||||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='卡投放'; | |||||
| @@ -0,0 +1,27 @@ | |||||
| insert into `mall_permission` ( `id`, `name`, `parent_id`, `available`, `permission`, `resource_type`, `module_color`, `module_color_num`, `url`, `icon`, `version_type`, `sort`) values ( '703', '系统发卡', '609', 'Y', null, '1', null, null, 'sysSendCardList', null, '0', '703'); | |||||
| DROP TABLE IF EXISTS `mall_sale_type` ; | |||||
| CREATE TABLE `mall_sale_type` ( | |||||
| `id` bigint(64) NOT NULL, | |||||
| `name` varchar(32) DEFAULT NULL COMMENT '销售类型', | |||||
| `type` tinyint(2) DEFAULT NULL COMMENT '资源类型1:尊享全能版 2:尊享营销版 3.速享版', | |||||
| `period` tinyint(2) DEFAULT NULL COMMENT '有效期(单位月)', | |||||
| `menus` json DEFAULT NULL COMMENT '菜单列表', | |||||
| PRIMARY KEY (`id`), | |||||
| UNIQUE `id_UNIQUE` USING BTREE (`id`) comment '' | |||||
| ) ENGINE=`InnoDB` ROW_FORMAT=DYNAMIC COMMENT='系统销售表' CHECKSUM=0 DELAY_KEY_WRITE=0; | |||||
| INSERT INTO `mall_sale_type` | |||||
| (`id`,`name`, `type`, `period`, `menus`) | |||||
| VALUES | |||||
| (1, '尊享全能版', 1, 12, | |||||
| '[1,2,3,4,5,6,7,8,9,10,50,101,102,103,104,105,106,107,108,201,202,203,204,205,206,211,212,221,222,251,299,300,301,302,303,304,305,306,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,501,502,503,504,505,506,507,508,509,511,512,513,521,522,523,531,532,533,591,592,595,601,602,603,604,605,606,607,608,609,610,611,612,621,622,623,624,625,626,627,641,642,643,644,645,651,661,662,663,671,672,673,674,681,682,683,684,685,691,692,693,694,695,701,702,703,711,712,713,901,902,903,931,932,951,952,961,962,965,966,967,968]' | |||||
| ), | |||||
| (2, '尊享营销版', 2, 12, | |||||
| '[1,2,4,5,6,7,8,9,10,50,101,102,103,104,105,106,107,201,202,203,204,205,211,212,221,222,251,409,410,411,416,501,502,503,504,505,506,507,508,509,511,512,513,521,522,523,531,532,533,591,592,595,601,602,603,604,605,606,607,608,609,610,611,612,621,622,623,624,625,626,627,641,642,643,644,645,651,661,662,663,671,672,673,674,681,682,683,684,685,691,692,693,694,695,701,702,703,711,712,713,901,902,903,931,932,951,961]' | |||||
| ), | |||||
| (3, '速享版', 3, 1, | |||||
| '[2,4,5,6,7,10,50,201,202,205,211,212,221,222,251,409,410,411,416,501,502,503,504,505,506,507,508,511,512,513,521,522,523,531,532,533,591,592,601,602,603,604,605,606,607,608,609,610,611,612,621,622,623,624,625,626,641,642,643,644,645,651,661,662,663,671,672,673,674,681,682,683,684,685,691,692,693,694,695,701,702,703,711,712,713,901,902,903,931,932]' | |||||
| ) | |||||
| ; | |||||
| @@ -0,0 +1,2 @@ | |||||
| alter table wx_coupon_present | |||||
| add column send_amount int(11) default 0 not null comment '发送数量'; | |||||
| @@ -0,0 +1,2 @@ | |||||
| alter table wx_msg_callback | |||||
| add column business_id bigint(20) default 0 not null comment '业务ID'; | |||||
| @@ -0,0 +1,2 @@ | |||||
| alter table wx_coupon_password | |||||
| add column present_id bigint(20) default 0 not null comment '发放ID'; | |||||
| @@ -12,8 +12,8 @@ import com.iformall.domain.vo.WxMerchantVo; | |||||
| import com.iformall.enums.*; | import com.iformall.enums.*; | ||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.service.*; | import com.iformall.service.*; | ||||
| import com.iformall.utils.ETCPUtil; | |||||
| import com.iformall.utils.TJDCarUtil; | |||||
| import com.iformall.utils.car.ETCPUtil; | |||||
| import com.iformall.utils.car.TJDUtil; | |||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| import io.swagger.annotations.ApiImplicitParams; | import io.swagger.annotations.ApiImplicitParams; | ||||
| @@ -37,7 +37,7 @@ public class WxCarController extends BaseController { | |||||
| ETCPUtil etcp = new ETCPUtil(); | ETCPUtil etcp = new ETCPUtil(); | ||||
| TJDCarUtil tjd = new TJDCarUtil(); | |||||
| TJDUtil tjd = new TJDUtil(); | |||||
| @Autowired | @Autowired | ||||
| WxParkService wxParkService; | WxParkService wxParkService; | ||||
| @@ -48,6 +48,9 @@ public class WxCarController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| WxMerchantService wxMerchantService; | WxMerchantService wxMerchantService; | ||||
| @Autowired | |||||
| WxCouponService couponService; | |||||
| @Autowired | @Autowired | ||||
| WxCouponOrderService wxCouponOrderService; | WxCouponOrderService wxCouponOrderService; | ||||
| @@ -241,16 +244,7 @@ public class WxCarController extends BaseController { | |||||
| * @param paramMap | * @param paramMap | ||||
| * @return | * @return | ||||
| */ | */ | ||||
| @ApiOperation(value = "绑车牌", notes = "ETCP:={\"etcpToken\":\"string\",\"carNumber\":\"string\"}\n" + | |||||
| "TJD:={\"carNumber\":\"string\",\"carNumColor\":\"string\",\"outCarId\":\"string\"}\n返回\n" + | |||||
| "{\n" + | |||||
| " \"timestamp\": \"1464235239561\",\n" + | |||||
| " \"returnCode\": \"T\",\n" + | |||||
| " \"errorMsg\": \"\",\n" + | |||||
| " \"returnMsg\": \"OK\",\n" + | |||||
| " \"isSuccess\": \"0\",\n" + | |||||
| " \"carId\": \"5836b8b52ada463ebc6199579f029561\"\n" + | |||||
| "}\n") | |||||
| @ApiOperation(value = "绑车牌", notes = "ETCP:={\"etcpToken\":\"string\",\"carNumber\":\"string\"}, TJD:={\"carNumber\":\"string\"}") | |||||
| @PostMapping("/bindCar") | @PostMapping("/bindCar") | ||||
| public ResultData bindCar(@RequestBody Map<String, String > paramMap) { | public ResultData bindCar(@RequestBody Map<String, String > paramMap) { | ||||
| // 1, get mall's park | // 1, get mall's park | ||||
| @@ -258,11 +252,10 @@ public class WxCarController extends BaseController { | |||||
| // 2. get vendor params | // 2. get vendor params | ||||
| if (park.getVendorType() == EnumCarVendor.CAR_ETCP.getCode()) { | if (park.getVendorType() == EnumCarVendor.CAR_ETCP.getCode()) { | ||||
| return etcpBindCar(paramMap, park); | return etcpBindCar(paramMap, park); | ||||
| } else { | |||||
| // 内部操作 | |||||
| return bindCar(paramMap, park); | |||||
| } | } | ||||
| else if (park.getVendorType() == EnumCarVendor.CAR_TJD.getCode()) { | |||||
| return tjdBindCar(paramMap, park); | |||||
| } | |||||
| return new ResultData(ErrorCode.CAR_VENDOR_NOT_SUPPORT.getCode(), "绑车牌失败"); | |||||
| } | } | ||||
| private ResultData etcpBindCar(Map<String, String> paramMap, WxPark park) { | private ResultData etcpBindCar(Map<String, String> paramMap, WxPark park) { | ||||
| @@ -292,7 +285,7 @@ public class WxCarController extends BaseController { | |||||
| } | } | ||||
| JSONObject retObj = JSON.parseObject(ret); | JSONObject retObj = JSON.parseObject(ret); | ||||
| if (retObj.getIntValue("code") == 0) { | if (retObj.getIntValue("code") == 0) { | ||||
| addCarInfoToDB(carNumber); | |||||
| addCarInfoToDB(carNumber, EnumCarVendor.CAR_ETCP); | |||||
| JSONObject dataObj = retObj.getJSONObject("data"); | JSONObject dataObj = retObj.getJSONObject("data"); | ||||
| return new ResultData(dataObj); | return new ResultData(dataObj); | ||||
| } else { | } else { | ||||
| @@ -302,14 +295,30 @@ public class WxCarController extends BaseController { | |||||
| } | } | ||||
| } | } | ||||
| private void addCarInfoToDB(String carNumber) { | |||||
| private ResultData bindCar(Map<String, String> paramMap, WxPark park) { | |||||
| String carNumber = paramMap.get("carNumber"); | |||||
| if (StringUtils.isBlank(carNumber)) { | |||||
| logger.error("carNumber为空"); | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "carNumber为空"); | |||||
| } | |||||
| try { | |||||
| addCarInfoToDB(carNumber, EnumCarVendor.getEnum(park.getVendorType())); | |||||
| } catch (MallinkException e) { | |||||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||||
| } catch (Exception e) { | |||||
| return new ResultData(500, e.getMessage()); | |||||
| } | |||||
| return new ResultData(); | |||||
| } | |||||
| private void addCarInfoToDB(String carNumber, EnumCarVendor carVendor) { | |||||
| // 插入车牌 | // 插入车牌 | ||||
| Date curr = new Date(); | Date curr = new Date(); | ||||
| WxCUserCar userCar = new WxCUserCar(); | WxCUserCar userCar = new WxCUserCar(); | ||||
| userCar.setCUserId(getUserId()); | userCar.setCUserId(getUserId()); | ||||
| userCar.setTenantId(getTenantId()); | userCar.setTenantId(getTenantId()); | ||||
| userCar.setCarNumber(carNumber); | userCar.setCarNumber(carNumber); | ||||
| userCar.setVendorType(EnumCarVendor.CAR_ETCP.getCode()); | |||||
| userCar.setVendorType(carVendor.getCode()); | |||||
| userCar.setCreateDate(curr); | userCar.setCreateDate(curr); | ||||
| userCar.setUpdateDate(curr); | userCar.setUpdateDate(curr); | ||||
| wxCUserCarService.saveOrUpdate(userCar); | wxCUserCarService.saveOrUpdate(userCar); | ||||
| @@ -409,26 +418,16 @@ public class WxCarController extends BaseController { | |||||
| " \"code\": 0,\n" + | " \"code\": 0,\n" + | ||||
| " \"message\": \"ok\"" + | " \"message\": \"ok\"" + | ||||
| "}" + | "}" + | ||||
| "TJD:={\"carNumber\":\"string\",\"carNumColor\":\"string\",\"outCarId\":\"string\"}\n返回:\n" + | |||||
| "{\n" + | |||||
| " \"timestamp\": \"1464235239561\",\n" + | |||||
| " \"returnCode\": \"T\",\n" + | |||||
| " \"errorMsg\": \"\",\n" + | |||||
| " \"returnMsg\": \"OK\",\n" + | |||||
| " \"isSuccess\": \"0\",\n" + | |||||
| "}\n") | |||||
| "TJD:={\"carNumber\":\"string\"}") | |||||
| @PostMapping("/unbindCar") | @PostMapping("/unbindCar") | ||||
| public ResultData unbindCar(@RequestBody Map<String, String > paramMap) { | public ResultData unbindCar(@RequestBody Map<String, String > paramMap) { | ||||
| // 1, get mall's park | // 1, get mall's park | ||||
| WxPark park = getCurrentPark(getTenantId()); | WxPark park = getCurrentPark(getTenantId()); | ||||
| if (park.getVendorType() == EnumCarVendor.CAR_ETCP.getCode()) { | |||||
| if (park.getVendorType().equals(EnumCarVendor.CAR_ETCP.getCode())) { | |||||
| return etcpUnbindCar(paramMap, park); | return etcpUnbindCar(paramMap, park); | ||||
| } else { | |||||
| return unbindCar(paramMap, park); | |||||
| } | } | ||||
| else if (park.getVendorType() == EnumCarVendor.CAR_TJD.getCode()) { | |||||
| ResultData e = tjdUnbindCar(paramMap, park); | |||||
| if (e != null) return e; | |||||
| } | |||||
| return new ResultData(ErrorCode.CAR_VENDOR_NOT_SUPPORT.getCode(), "解绑车牌失败"); | |||||
| } | } | ||||
| private ResultData etcpUnbindCar(Map<String, String> paramMap, WxPark park) { | private ResultData etcpUnbindCar(Map<String, String> paramMap, WxPark park) { | ||||
| @@ -478,6 +477,26 @@ public class WxCarController extends BaseController { | |||||
| } | } | ||||
| } | } | ||||
| private ResultData unbindCar(Map<String, String> paramMap, WxPark park) { | |||||
| String carNumber = paramMap.get("carNumber"); | |||||
| if (StringUtils.isBlank(carNumber)) { | |||||
| logger.error("carNumber为空"); | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "carNumber为空"); | |||||
| } | |||||
| try { | |||||
| WxCUserCar userCar = new WxCUserCar(); | |||||
| userCar.setTenantId(getTenantId()); | |||||
| userCar.setCUserId(getUserId()); | |||||
| userCar.setCarNumber(carNumber); | |||||
| wxCUserCarService.deleteByObj(userCar); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(ErrorCode.DB_FAIL.getCode(), "解绑车牌数据库错误, e:" + e.getMessage()); | |||||
| } | |||||
| return new ResultData(); | |||||
| } | |||||
| private ResultData tjdUnbindCar(@RequestBody Map<String, String> paramMap, WxPark park) { | private ResultData tjdUnbindCar(@RequestBody Map<String, String> paramMap, WxPark park) { | ||||
| String carNumber = paramMap.get("carNumber"); | String carNumber = paramMap.get("carNumber"); | ||||
| if (StringUtils.isBlank(carNumber)) { | if (StringUtils.isBlank(carNumber)) { | ||||
| @@ -536,7 +555,7 @@ public class WxCarController extends BaseController { | |||||
| " \"paidFee\": 0,\n" + | " \"paidFee\": 0,\n" + | ||||
| " \"verificationInfo\": \"FSED9JvxgAU6XJUd8YRF5YH/LpfQYzCAfcPbAOKPV3BjKSatbgIsh7EBH2JBiRoGBe3btr gzKRMTfIoFuCn1XX7HUsJYlb7JSCBArnNmEVU4JuDLLjzoqB7qhQ8KnP16\"\n" + | " \"verificationInfo\": \"FSED9JvxgAU6XJUd8YRF5YH/LpfQYzCAfcPbAOKPV3BjKSatbgIsh7EBH2JBiRoGBe3btr gzKRMTfIoFuCn1XX7HUsJYlb7JSCBArnNmEVU4JuDLLjzoqB7qhQ8KnP16\"\n" + | ||||
| " }" + | " }" + | ||||
| "TJD:={\"carNumber\":\"string\",\"carNumColor\":\"string\",\"outCarId\":\"string\"}\n输出\n{\n" + | |||||
| "TJD:={\"carNumber\":\"string\"}\n输出\n{\n" + | |||||
| " \"inDt\": \"20160526112000\",\n" + | " \"inDt\": \"20160526112000\",\n" + | ||||
| " \"timestamp\": \"1464235239561\",\n" + | " \"timestamp\": \"1464235239561\",\n" + | ||||
| " \"returnCode\": \"T\",\n" + | " \"returnCode\": \"T\",\n" + | ||||
| @@ -628,13 +647,13 @@ public class WxCarController extends BaseController { | |||||
| } | } | ||||
| String params = park.getVendorParams(); | String params = park.getVendorParams(); | ||||
| JSONObject objParams = JSON.parseObject(params); | JSONObject objParams = JSON.parseObject(params); | ||||
| String url = objParams.getString("url"); | |||||
| String partner = objParams.getString("partner"); | |||||
| String key = objParams.getString("key"); | |||||
| String version = objParams.getString("version"); | |||||
| String url = objParams.getString(TJDUtil.TJD_URL); | |||||
| String partner = objParams.getString(TJDUtil.TJD_ACCOUNT); | |||||
| String key = objParams.getString(TJDUtil.TJD_ACCOUNT_KEY); | |||||
| String version = objParams.getString(TJDUtil.TJD_VERSION); | |||||
| String ret = tjd.infoForFreeMins(url, partner, key, version, carNumber); | String ret = tjd.infoForFreeMins(url, partner, key, version, carNumber); | ||||
| JSONObject retObj = JSON.parseObject(ret); | JSONObject retObj = JSON.parseObject(ret); | ||||
| if (retObj.getString("returnCode").equalsIgnoreCase(EnumTJDCode.SUCCESS.getMessage())) { | |||||
| if (retObj.getString(TJDUtil.TJD_RETURN_CODE).equalsIgnoreCase(EnumTJDCode.SUCCESS.getMessage())) { | |||||
| return new ResultData(retObj); | return new ResultData(retObj); | ||||
| } else { | } else { | ||||
| return new ResultData(ErrorCode.TJD_STOP_FEE_FAIL.getCode(), "停车费获取失败"); | return new ResultData(ErrorCode.TJD_STOP_FEE_FAIL.getCode(), "停车费获取失败"); | ||||
| @@ -645,44 +664,36 @@ public class WxCarController extends BaseController { | |||||
| * 停车费抵扣 | * 停车费抵扣 | ||||
| * | * | ||||
| */ | */ | ||||
| @ApiOperation(value = "停车费抵扣", notes = "{\"tradeId\":\"string\",\"deductionAmount\":\"string\",\"accountId\":\"string\",\"orderId\":\"string\"}\nresult\n{\n" + | |||||
| " \"timestamp\": \"1464235239561\",\n" + | |||||
| " \"returnCode\": \"T\",\n" + | |||||
| " \"errorMsg\": \"\",\n" + | |||||
| " \"returnMsg\": \"OK\",\n" + | |||||
| " \"isSuccess\": \"0\",\n" + | |||||
| " \"carId\": \"5836b8b52ada463ebc6199579f029561\"\n" + | |||||
| " }") | |||||
| @ApiOperation(value = "停车费抵扣", notes ="TJD: {\"tradeId\":\"string\",\"accountId\":\"string\",\"couponOrderId\":\"string\"}") | |||||
| @PostMapping("/deductionFee") | @PostMapping("/deductionFee") | ||||
| public ResultData deductionFee(@RequestBody Map<String, String > paramMap) { | public ResultData deductionFee(@RequestBody Map<String, String > paramMap) { | ||||
| /// 1, get mall's park | /// 1, get mall's park | ||||
| WxPark park = getCurrentPark(getTenantId()); | WxPark park = getCurrentPark(getTenantId()); | ||||
| if (park.getVendorType() == EnumCarVendor.CAR_TJD.getCode()) { | if (park.getVendorType() == EnumCarVendor.CAR_TJD.getCode()) { | ||||
| String tradeId = paramMap.get("tradeId"); | String tradeId = paramMap.get("tradeId"); | ||||
| String deductionAmount = paramMap.get("deductionAmount"); | |||||
| String accountId = paramMap.get("accountId"); | String accountId = paramMap.get("accountId"); | ||||
| String outTradeNo = paramMap.get("orderId"); | |||||
| String outTradeNo = paramMap.get("couponOrderId"); | |||||
| if (StringUtils.isBlank(tradeId)) { | if (StringUtils.isBlank(tradeId)) { | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "tradeId为空"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "tradeId为空"); | ||||
| } | } | ||||
| if (StringUtils.isBlank(deductionAmount)) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "deductionAmount为空"); | |||||
| } | |||||
| if (StringUtils.isBlank(accountId)) { | if (StringUtils.isBlank(accountId)) { | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "accountId为空"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "accountId为空"); | ||||
| } | } | ||||
| if (StringUtils.isBlank(outTradeNo)) { | if (StringUtils.isBlank(outTradeNo)) { | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "orderId为空"); | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponOrderId为空"); | |||||
| } | } | ||||
| WxCouponOrder couponOrder = wxCouponOrderService.getById(Long.valueOf(outTradeNo)); | |||||
| WxCoupon coupon = couponService.getById(couponOrder.getCouponId()); | |||||
| String params = park.getVendorParams(); | String params = park.getVendorParams(); | ||||
| JSONObject objParams = JSON.parseObject(params); | JSONObject objParams = JSON.parseObject(params); | ||||
| String url = objParams.getString("url"); | String url = objParams.getString("url"); | ||||
| String partner = objParams.getString("partner"); | String partner = objParams.getString("partner"); | ||||
| String key = objParams.getString("key"); | String key = objParams.getString("key"); | ||||
| String version = objParams.getString("version"); | String version = objParams.getString("version"); | ||||
| String ret = tjd.deductionNotSettle(url, partner, key, version, tradeId, deductionAmount, outTradeNo, accountId); | |||||
| String ret = tjd.deductionForDetail(url, partner, key, version, | |||||
| tradeId, accountId, couponOrder, coupon); | |||||
| JSONObject retObj = JSON.parseObject(ret); | JSONObject retObj = JSON.parseObject(ret); | ||||
| if (retObj.getString("returnCode").equalsIgnoreCase(EnumTJDCode.SUCCESS.getMessage())) { | |||||
| if (retObj.getString(TJDUtil.TJD_RETURN_CODE).equalsIgnoreCase(EnumTJDCode.SUCCESS.getMessage())) { | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } else { | } else { | ||||
| return new ResultData(ErrorCode.TJD_DEDUCE_FEE_FAIL.getCode(), "停车费抵扣失败"); | return new ResultData(ErrorCode.TJD_DEDUCE_FEE_FAIL.getCode(), "停车费抵扣失败"); | ||||
| @@ -0,0 +1,100 @@ | |||||
| package com.iformall.controller; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.*; | |||||
| import com.iformall.enums.*; | |||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.service.*; | |||||
| import com.iformall.utils.Constant; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import java.util.Date; | |||||
| import java.util.Map; | |||||
| @RestController | |||||
| @RequestMapping("/api/couponPassword") | |||||
| @Api(description = "卡密相关接口") | |||||
| public class WxCouponPasswordController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxCouponPasswordService couponPasswordService; | |||||
| @Autowired | |||||
| private WxCouponService couponService; | |||||
| @Autowired | |||||
| private WxOrderService orderService; | |||||
| @ApiOperation(value = "根据卡密领卡", notes = "{\"password\":\"String\",\"formId\":\"String\"}") | |||||
| @PostMapping("getCouponOrderByPassword") | |||||
| public ResultData getCouponOrderByPassword(@RequestBody Map<String, String> params) { | |||||
| logger.info("getCouponOrderByPassword: " + getIpAddr() + params.toString()); | |||||
| String password = params.get("password"); | |||||
| String formId = params.get("formId"); | |||||
| if (StringUtils.isBlank(password) || password.equalsIgnoreCase(Constant.UNDEFINED)) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "password不能为空"); | |||||
| } | |||||
| // 1. 根据password获取领取的couponId | |||||
| WxCouponPassword couponPasswordQ = new WxCouponPassword(); | |||||
| couponPasswordQ.setTenantId(getTenantId()); | |||||
| couponPasswordQ.setPassword(password); | |||||
| couponPasswordQ.setExpireDate(new Date()); | |||||
| WxCouponPassword couponPassword = null; | |||||
| try { | |||||
| couponPassword = couponPasswordService.getByObj(couponPasswordQ); | |||||
| } catch (MallinkException e) { | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(500, e.getMessage()); | |||||
| } | |||||
| WxCUser cuUser = getUser(); | |||||
| WxCoupon coupon = couponService.getById(couponPassword.getCouponId()); | |||||
| if (coupon == null) { | |||||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY); | |||||
| } | |||||
| if (coupon.getStatus().equals(EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode())) { | |||||
| logger.error("此券已作废:" + coupon.getId()); | |||||
| return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF); | |||||
| } | |||||
| // 卡密领取卡券 | |||||
| Integer pwdStatus = couponPassword.getStatus(); | |||||
| setCouponPasswordStatus(couponPassword, EnumCouponPasswordStatus.USED); | |||||
| couponPassword.setStatus(EnumCouponPasswordStatus.USED.getCode()); | |||||
| // 3. 领取free coupon | |||||
| try { | |||||
| WxOrder order = orderService.saveFreeOrderForCoupon(cuUser, coupon, null, formId, couponPassword.getId()); | |||||
| } catch (MallinkException e) { | |||||
| setCouponPasswordStatus(couponPassword, EnumCouponPasswordStatus.getEnum(pwdStatus)); | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||||
| } catch (Exception e) { | |||||
| setCouponPasswordStatus(couponPassword, EnumCouponPasswordStatus.getEnum(pwdStatus)); | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(500, e.getMessage()); | |||||
| } | |||||
| return new ResultData(); | |||||
| } | |||||
| private void setCouponPasswordStatus(WxCouponPassword couponPassword, EnumCouponPasswordStatus pwdStatus) { | |||||
| WxCouponPassword updateCouponPwd = new WxCouponPassword(); | |||||
| updateCouponPwd.setId(couponPassword.getId()); | |||||
| updateCouponPwd.setStatus(pwdStatus.getCode()); | |||||
| couponPasswordService.saveOrUpdate(updateCouponPwd); | |||||
| } | |||||
| } | |||||
| @@ -83,6 +83,9 @@ public class WxOrderController extends BaseController { | |||||
| if (coupon == null) { | if (coupon == null) { | ||||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY); | return new ResultData(ErrorCode.COUPON_IS_EMPTY); | ||||
| } | } | ||||
| if (coupon.getStatus().equals(EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode())) { | |||||
| return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF); | |||||
| } | |||||
| WxOrder order = wxOrderService.saveOrderForCoupon(user, coupon, orderSaveDto, isPress); | WxOrder order = wxOrderService.saveOrderForCoupon(user, coupon, orderSaveDto, isPress); | ||||
| return new ResultData(order); | return new ResultData(order); | ||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| @@ -12,7 +12,7 @@ import com.iformall.enums.EnumCouponSendSendType; | |||||
| import com.iformall.enums.EnumETCPCode; | import com.iformall.enums.EnumETCPCode; | ||||
| import com.iformall.service.*; | import com.iformall.service.*; | ||||
| import com.iformall.utils.DateUtils; | import com.iformall.utils.DateUtils; | ||||
| import com.iformall.utils.ETCPUtil; | |||||
| import com.iformall.utils.car.ETCPUtil; | |||||
| import org.apache.commons.collections.CollectionUtils; | import org.apache.commons.collections.CollectionUtils; | ||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| @@ -32,7 +32,7 @@ import java.util.Map; | |||||
| @RestController | @RestController | ||||
| @RequestMapping("/carCallback") | @RequestMapping("/carCallback") | ||||
| public class WxCarCallBackController extends BaseController { | |||||
| public class WxCarETCPCallBackController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
| @Autowired | @Autowired | ||||
| @@ -81,119 +81,6 @@ public class WxCarCallBackController extends BaseController { | |||||
| return new Result(EnumETCPCode.SUCCESS.getCode(), EnumETCPCode.SUCCESS.getMessage()); | return new Result(EnumETCPCode.SUCCESS.getCode(), EnumETCPCode.SUCCESS.getMessage()); | ||||
| } | } | ||||
| // @Async | |||||
| private boolean doEtcpParkIn(@RequestBody Map<String, String> paramMap) { | |||||
| Date currentDate = new Date(); | |||||
| WxCarCmdLog wxCarCmdLog = new WxCarCmdLog(); | |||||
| wxCarCmdLog.setVendorType(EnumCarVendor.CAR_ETCP.getCode()); | |||||
| wxCarCmdLog.setCmdType(EnumCarCmd.CAR_ETCP_CALLBACK_PARK_IN.getCode()); | |||||
| wxCarCmdLog.setCmdJson(JSON.toJSONString(paramMap)); | |||||
| wxCarCmdLog.setCreateDate(currentDate); | |||||
| wxCarCmdLog.setUpdateDate(currentDate); | |||||
| String etcpParkId = paramMap.get(ETCPUtil.ETCP_PARK_ID); | |||||
| String tenantId = null; | |||||
| WxPark parkQ = new WxPark(); | |||||
| parkQ.setVendorType(EnumCarVendor.CAR_ETCP.getCode()); | |||||
| parkQ.setParkingId(etcpParkId); | |||||
| WxPark park = wxParkService.getByObj(parkQ); | |||||
| if (park == null) { | |||||
| logger.error("etcpParkInCallback: ETCP车场未找到" + etcpParkId); | |||||
| //return new Result(ErrorCode.CAR_PARK_NOT_FOUND.getCode(), "ETCP车场未找到"+ etcpParkId); | |||||
| } else { | |||||
| tenantId = park.getTenantId(); | |||||
| wxCarCmdLog.setTenantId(park.getTenantId()); | |||||
| } | |||||
| String carNumber = paramMap.get(ETCPUtil.ETCP_CAR_NUMBER); | |||||
| String synId = paramMap.get(ETCPUtil.ETCP_SYN_ID); | |||||
| String parkId = paramMap.get(ETCPUtil.ETCP_PARK_ID); | |||||
| String parkName = paramMap.get(ETCPUtil.ETCP_PARK_NAME); | |||||
| String userType = paramMap.get(ETCPUtil.ETCP_USER_TYPE); | |||||
| String entranceTime = paramMap.get(ETCPUtil.ETCP_ENTRANCE_TIME); | |||||
| String fixParkingId = paramMap.get(ETCPUtil.ETCP_FIX_PARKING_ID); | |||||
| String remainingDays = paramMap.get(ETCPUtil.ETCP_REMAINING_DAYS); | |||||
| // 检查是否有重复数据 | |||||
| HashMap<String, Object> map = new HashMap<String, Object>(); | |||||
| map.put("synId", synId); | |||||
| map.put("cmdType", EnumCarCmd.CAR_ETCP_CALLBACK_PARK_IN.getCode()); | |||||
| if(tenantId != null) { | |||||
| map.put("tenantId", tenantId); | |||||
| } | |||||
| WxCarCmdLog carCmdLog = wxCarCmdLogService.getBySynId(map); | |||||
| if(carCmdLog != null) { | |||||
| logger.error("ETCP synId已入库: " + paramMap.toString()); | |||||
| return true; | |||||
| } | |||||
| try { | |||||
| wxCarCmdLogService.saveOrUpdate(wxCarCmdLog); | |||||
| } catch (Exception e) { | |||||
| logger.error("etcpParkInCallback: 入库错误 " + e.getMessage() + "\n" + paramMap.toString()); | |||||
| return true; | |||||
| } | |||||
| String phoneStrs = ""; | |||||
| // 停车发券 | |||||
| if (!StringUtils.isBlank(carNumber)) { | |||||
| // 根据车牌查找用户 | |||||
| WxCUserCar userCarQ = new WxCUserCar(); | |||||
| userCarQ.setTenantId(tenantId); | |||||
| userCarQ.setCarNumber(carNumber); | |||||
| userCarQ.setVendorType(EnumCarVendor.CAR_ETCP.getCode()); | |||||
| // TODO 可能多用户关联同一张车牌 | |||||
| List<WxCUserCar> userCarList = wxCUserCarService.getList(userCarQ); | |||||
| boolean bFirst = true; | |||||
| for (WxCUserCar userCar : userCarList) { | |||||
| wxCouponSendService.sendCouponToUser(EnumCouponSendSendType.CAR_STOP, userCar); | |||||
| WxCUser cUser = wxCUserService.getById(userCar.getCUserId()); | |||||
| if(cUser != null){ | |||||
| if(bFirst) { | |||||
| phoneStrs = cUser.getPhone(); | |||||
| bFirst = false; | |||||
| } else { | |||||
| phoneStrs += "," + cUser.getPhone(); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| try { | |||||
| // 保存WxCarPayRecord | |||||
| WxCarPayRecord record = new WxCarPayRecord(); | |||||
| record.setVendorType(wxCarCmdLog.getVendorType()); | |||||
| record.setSynId(synId); | |||||
| record.setParkId(parkId); | |||||
| record.setParkName(parkName); | |||||
| record.setUserType(userType); | |||||
| record.setPlateNumber(carNumber); | |||||
| if(StringUtils.isNotBlank(entranceTime)) { | |||||
| record.setEntranceTime(dateFormat.parse(entranceTime)); | |||||
| } | |||||
| record.setFixParkingId(fixParkingId); | |||||
| record.setRemainingDays(remainingDays); | |||||
| record.setPhone(phoneStrs); | |||||
| record.setTenantId(tenantId); | |||||
| WxCarPayRecord query = new WxCarPayRecord(); | |||||
| query.setSynId(synId); | |||||
| PageInfo<WxCarPayRecord> page = wxCarPayRecordService.findCarPayListByPage(query,1,1); | |||||
| if(page != null && CollectionUtils.isNotEmpty(page.getList())){ | |||||
| record.setId(page.getList().get(0).getId()); | |||||
| } | |||||
| wxCarPayRecordService.saveOrUpdate(record); | |||||
| } catch (Exception e) { | |||||
| e.printStackTrace(); | |||||
| logger.error("WxCarPayRecord: 入库错误 ",e); | |||||
| logger.error("WxCarPayRecord: 入库错误 "+e.getMessage()+"," + paramMap.toString()); | |||||
| return true; | |||||
| } | |||||
| return false; | |||||
| } | |||||
| /** | /** | ||||
| * ETCP 车辆出场通知 | * ETCP 车辆出场通知 | ||||
| * { | * { | ||||
| @@ -221,86 +108,6 @@ public class WxCarCallBackController extends BaseController { | |||||
| return new Result(EnumETCPCode.SUCCESS.getCode(), EnumETCPCode.SUCCESS.getMessage()); | return new Result(EnumETCPCode.SUCCESS.getCode(), EnumETCPCode.SUCCESS.getMessage()); | ||||
| } | } | ||||
| private boolean doEtcpParkOut(@RequestBody Map<String, String> paramMap) { | |||||
| Date currentDate = new Date(); | |||||
| WxCarCmdLog wxCarCmdLog = new WxCarCmdLog(); | |||||
| wxCarCmdLog.setVendorType(EnumCarVendor.CAR_ETCP.getCode()); | |||||
| wxCarCmdLog.setCmdType(EnumCarCmd.CAR_ETCP_CALLBACK_PARK_OUT.getCode()); | |||||
| wxCarCmdLog.setCmdJson(JSON.toJSONString(paramMap)); | |||||
| wxCarCmdLog.setCreateDate(currentDate); | |||||
| wxCarCmdLog.setUpdateDate(currentDate); | |||||
| String etcpParkId = paramMap.get(ETCPUtil.ETCP_PARK_ID); | |||||
| String tenantId = null; | |||||
| WxPark parkQ = new WxPark(); | |||||
| parkQ.setVendorType(EnumCarVendor.CAR_ETCP.getCode()); | |||||
| parkQ.setParkingId(etcpParkId); | |||||
| WxPark park = wxParkService.getByObj(parkQ); | |||||
| if (park == null) { | |||||
| logger.error("etcpParkOutCallback: ETCP车场未找到 " + etcpParkId); | |||||
| // return new Result(ErrorCode.CAR_PARK_NOT_FOUND.getCode(), "ETCP车场未找到"+ etcpParkId); | |||||
| } else { | |||||
| tenantId = park.getTenantId(); | |||||
| wxCarCmdLog.setTenantId(tenantId); | |||||
| } | |||||
| try { | |||||
| wxCarCmdLogService.saveOrUpdate(wxCarCmdLog); | |||||
| } catch (Exception e) { | |||||
| logger.error("etcpParkOutCallback: 入库错误 " + e.getMessage() + "\n" + paramMap.toString()); | |||||
| return true; | |||||
| } | |||||
| String synId = paramMap.get(ETCPUtil.ETCP_SYN_ID); | |||||
| String exitTime = paramMap.get(ETCPUtil.ETCP_EXIT_TIME); | |||||
| String stayedTime = paramMap.get(ETCPUtil.ETCP_STAYED_TIME); | |||||
| String carNumber = paramMap.get(ETCPUtil.ETCP_CAR_NUMBER); | |||||
| String parkId = paramMap.get(ETCPUtil.ETCP_PARK_ID); | |||||
| String parkName = paramMap.get(ETCPUtil.ETCP_PARK_NAME); | |||||
| String userType = paramMap.get(ETCPUtil.ETCP_USER_TYPE); | |||||
| String entranceTime = paramMap.get(ETCPUtil.ETCP_ENTRANCE_TIME); | |||||
| String fixParkingId = paramMap.get(ETCPUtil.ETCP_FIX_PARKING_ID); | |||||
| String remainingDays = paramMap.get(ETCPUtil.ETCP_REMAINING_DAYS); | |||||
| try { | |||||
| // 保存WxCarPayRecord | |||||
| WxCarPayRecord record = new WxCarPayRecord(); | |||||
| record.setSynId(synId); | |||||
| if(StringUtils.isNotBlank(exitTime)) { | |||||
| record.setExitTime(dateFormat.parse(exitTime)); | |||||
| } | |||||
| if(StringUtils.isNotBlank(stayedTime)) { | |||||
| record.setStayedTime(Long.parseLong(stayedTime)); | |||||
| } | |||||
| record.setVendorType(wxCarCmdLog.getVendorType()); | |||||
| record.setSynId(synId); | |||||
| record.setParkId(parkId); | |||||
| record.setParkName(parkName); | |||||
| record.setUserType(userType); | |||||
| record.setPlateNumber(carNumber); | |||||
| if(StringUtils.isNotBlank(entranceTime)) { | |||||
| record.setEntranceTime(dateFormat.parse(entranceTime)); | |||||
| } | |||||
| record.setFixParkingId(fixParkingId); | |||||
| record.setRemainingDays(remainingDays); | |||||
| //record.setPhone(phoneStrs); | |||||
| record.setTenantId(tenantId); | |||||
| WxCarPayRecord query = new WxCarPayRecord(); | |||||
| query.setSynId(synId); | |||||
| PageInfo<WxCarPayRecord> page = wxCarPayRecordService.findCarPayListByPage(query,1,1); | |||||
| if(page != null && CollectionUtils.isNotEmpty(page.getList())){ | |||||
| record.setId(page.getList().get(0).getId()); | |||||
| } | |||||
| wxCarPayRecordService.saveOrUpdate(record); | |||||
| } catch (Exception e) { | |||||
| logger.error("WxCarPayRecord: 出场更新错误 " +e.getMessage()+", " +paramMap.toString()); | |||||
| return true; | |||||
| } | |||||
| return false; | |||||
| } | |||||
| /** | /** | ||||
| * ETCP 车辆解绑通知 | * ETCP 车辆解绑通知 | ||||
| * { | * { | ||||
| @@ -471,105 +278,196 @@ public class WxCarCallBackController extends BaseController { | |||||
| return new Result(EnumETCPCode.SUCCESS.getCode(), EnumETCPCode.SUCCESS.getMessage()); | return new Result(EnumETCPCode.SUCCESS.getCode(), EnumETCPCode.SUCCESS.getMessage()); | ||||
| } | } | ||||
| // @Async | |||||
| private boolean doEtcpParkIn(@RequestBody Map<String, String> paramMap) { | |||||
| Date currentDate = new Date(); | |||||
| WxCarCmdLog wxCarCmdLog = new WxCarCmdLog(); | |||||
| /** | |||||
| * TJD 车辆入场通知 | |||||
| * { | |||||
| * "tradeId": "5836b8b52ada463ebc6199579f029565", | |||||
| * "outCarId": "45454545454", | |||||
| * "carNum": "京A45413", | |||||
| * "carNumColor ": "blue", | |||||
| * "inDt": "20170319202020", | |||||
| * "parkName": "测试停车场", | |||||
| * "parkId": "5836b8b52ada463ebc6199579f029561", | |||||
| * "lon": "74.000272", | |||||
| * "lat": "159.768703", | |||||
| * "wLon": "123.523032", | |||||
| * "wLat": "35.430735", | |||||
| * "payUrl": "http://prep.tingjiandan.com/tcweixin/letter/prePay/payInPark.html?prePayType=16&channel=10001", | |||||
| * "canFindCar": "0" | |||||
| * } | |||||
| */ | |||||
| @RequestMapping(value = "/tjdParkInCallback") | |||||
| public Map tjdParkInCallback(@RequestBody Map<String, String> paramMap) { | |||||
| logger.info("["+getIpAddr()+"tjdParkInCallback: " + paramMap.toString()); | |||||
| Map map = new HashMap(); | |||||
| String tjdParkId = paramMap.get("parkId"); | |||||
| wxCarCmdLog.setVendorType(EnumCarVendor.CAR_ETCP.getCode()); | |||||
| wxCarCmdLog.setCmdType(EnumCarCmd.CAR_ETCP_CALLBACK_PARK_IN.getCode()); | |||||
| wxCarCmdLog.setCmdJson(JSON.toJSONString(paramMap)); | |||||
| wxCarCmdLog.setCreateDate(currentDate); | |||||
| wxCarCmdLog.setUpdateDate(currentDate); | |||||
| String etcpParkId = paramMap.get(ETCPUtil.ETCP_PARK_ID); | |||||
| String tenantId = null; | |||||
| WxPark parkQ = new WxPark(); | WxPark parkQ = new WxPark(); | ||||
| parkQ.setVendorType(EnumCarVendor.CAR_TJD.getCode()); | |||||
| parkQ.setParkId(tjdParkId); | |||||
| parkQ.setVendorType(EnumCarVendor.CAR_ETCP.getCode()); | |||||
| parkQ.setParkingId(etcpParkId); | |||||
| WxPark park = wxParkService.getByObj(parkQ); | WxPark park = wxParkService.getByObj(parkQ); | ||||
| if (park == null) { | if (park == null) { | ||||
| logger.error("tjdParkInCallback: 停简单车场未找到" + tjdParkId); | |||||
| map.put("isSuccess", "0"); | |||||
| map.put("errorMsg", "停简单车场未找到" + tjdParkId); | |||||
| return map; | |||||
| logger.error("etcpParkInCallback: ETCP车场未找到" + etcpParkId); | |||||
| //return new Result(ErrorCode.CAR_PARK_NOT_FOUND.getCode(), "ETCP车场未找到"+ etcpParkId); | |||||
| } else { | |||||
| tenantId = park.getTenantId(); | |||||
| wxCarCmdLog.setTenantId(park.getTenantId()); | |||||
| } | |||||
| String carNumber = paramMap.get(ETCPUtil.ETCP_CAR_NUMBER); | |||||
| String synId = paramMap.get(ETCPUtil.ETCP_SYN_ID); | |||||
| String parkId = paramMap.get(ETCPUtil.ETCP_PARK_ID); | |||||
| String parkName = paramMap.get(ETCPUtil.ETCP_PARK_NAME); | |||||
| String userType = paramMap.get(ETCPUtil.ETCP_USER_TYPE); | |||||
| String entranceTime = paramMap.get(ETCPUtil.ETCP_ENTRANCE_TIME); | |||||
| String fixParkingId = paramMap.get(ETCPUtil.ETCP_FIX_PARKING_ID); | |||||
| String remainingDays = paramMap.get(ETCPUtil.ETCP_REMAINING_DAYS); | |||||
| // 检查是否有重复数据 | |||||
| HashMap<String, Object> map = new HashMap<String, Object>(); | |||||
| map.put("synId", synId); | |||||
| map.put("cmdType", EnumCarCmd.CAR_ETCP_CALLBACK_PARK_IN.getCode()); | |||||
| if(tenantId != null) { | |||||
| map.put("tenantId", tenantId); | |||||
| } | |||||
| WxCarCmdLog carCmdLog = wxCarCmdLogService.getBySynId(map); | |||||
| if(carCmdLog != null) { | |||||
| logger.error("ETCP synId已入库: " + paramMap.toString()); | |||||
| return true; | |||||
| } | } | ||||
| Date currentDate = new Date(); | |||||
| WxCarCmdLog wxCarCmdLog = new WxCarCmdLog(); | |||||
| wxCarCmdLog.setTenantId(park.getTenantId()); | |||||
| wxCarCmdLog.setVendorType(EnumCarVendor.CAR_TJD.getCode()); | |||||
| wxCarCmdLog.setCmdType(EnumCarCmd.CAR_ETCP_CALLBACK_PARK_IN.getCode()); | |||||
| wxCarCmdLog.setCmdJson(JSON.toJSONString(paramMap)); | |||||
| wxCarCmdLog.setCreateDate(currentDate); | |||||
| wxCarCmdLog.setUpdateDate(currentDate); | |||||
| try { | try { | ||||
| wxCarCmdLogService.saveOrUpdate(wxCarCmdLog); | wxCarCmdLogService.saveOrUpdate(wxCarCmdLog); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error("tjdParkInCallback: 入库错误" + paramMap.toString()); | |||||
| map.put("isSuccess", "0"); | |||||
| map.put("errorMsg", "入库错误" + paramMap.toString()); | |||||
| return map; | |||||
| logger.error("etcpParkInCallback: 入库错误 " + e.getMessage() + "\n" + paramMap.toString()); | |||||
| return true; | |||||
| } | } | ||||
| map.put("isSuccess", "0"); | |||||
| map.put("errorMsg", ""); | |||||
| return map; | |||||
| } | |||||
| String phoneStrs = ""; | |||||
| /** | |||||
| * TJD 车辆出场通知 | |||||
| * { | |||||
| * "tradeId": "5836b8b52ada463ebc6199579f029565", | |||||
| * "outDt": "20170319232020", | |||||
| * "lon": "74.000272", | |||||
| * "lat": "159.768703", | |||||
| * "wLon": "123.523032", | |||||
| * "wLat": "35.430735", | |||||
| * "parkAmount": "5.20" | |||||
| * } | |||||
| */ | |||||
| @RequestMapping(value = "/tjdParkoutCallback") | |||||
| public Map tjdParkOutCallback(@RequestBody Map<String, String> paramMap) { | |||||
| logger.info("["+getIpAddr()+"tjdParkoutCallback: " + paramMap.toString()); | |||||
| Map map = new HashMap(); | |||||
| // 停车发券 | |||||
| if (!StringUtils.isBlank(carNumber)) { | |||||
| // 根据车牌查找用户 | |||||
| WxCUserCar userCarQ = new WxCUserCar(); | |||||
| userCarQ.setTenantId(tenantId); | |||||
| userCarQ.setCarNumber(carNumber); | |||||
| userCarQ.setVendorType(EnumCarVendor.CAR_ETCP.getCode()); | |||||
| // TODO 可能多用户关联同一张车牌 | |||||
| List<WxCUserCar> userCarList = wxCUserCarService.getList(userCarQ); | |||||
| boolean bFirst = true; | |||||
| for (WxCUserCar userCar : userCarList) { | |||||
| wxCouponSendService.sendCouponToUser(EnumCouponSendSendType.CAR_STOP, userCar); | |||||
| WxCUser cUser = wxCUserService.getById(userCar.getCUserId()); | |||||
| if(cUser != null){ | |||||
| if(bFirst) { | |||||
| phoneStrs = cUser.getPhone(); | |||||
| bFirst = false; | |||||
| } else { | |||||
| phoneStrs += "," + cUser.getPhone(); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| try { | |||||
| // 保存WxCarPayRecord | |||||
| WxCarPayRecord record = new WxCarPayRecord(); | |||||
| record.setVendorType(wxCarCmdLog.getVendorType()); | |||||
| record.setSynId(synId); | |||||
| record.setParkId(parkId); | |||||
| record.setParkName(parkName); | |||||
| record.setUserType(userType); | |||||
| record.setPlateNumber(carNumber); | |||||
| if(StringUtils.isNotBlank(entranceTime)) { | |||||
| record.setEntranceTime(dateFormat.parse(entranceTime)); | |||||
| } | |||||
| record.setFixParkingId(fixParkingId); | |||||
| record.setRemainingDays(remainingDays); | |||||
| record.setPhone(phoneStrs); | |||||
| record.setTenantId(tenantId); | |||||
| String tradeId = paramMap.get("tradeId"); | |||||
| WxCarPayRecord query = new WxCarPayRecord(); | |||||
| query.setSynId(synId); | |||||
| PageInfo<WxCarPayRecord> page = wxCarPayRecordService.findCarPayListByPage(query,1,1); | |||||
| if(page != null && CollectionUtils.isNotEmpty(page.getList())){ | |||||
| record.setId(page.getList().get(0).getId()); | |||||
| } | |||||
| wxCarPayRecordService.saveOrUpdate(record); | |||||
| } catch (Exception e) { | |||||
| e.printStackTrace(); | |||||
| logger.error("WxCarPayRecord: 入库错误 ",e); | |||||
| logger.error("WxCarPayRecord: 入库错误 "+e.getMessage()+"," + paramMap.toString()); | |||||
| return true; | |||||
| } | |||||
| return false; | |||||
| } | |||||
| private boolean doEtcpParkOut(@RequestBody Map<String, String> paramMap) { | |||||
| Date currentDate = new Date(); | Date currentDate = new Date(); | ||||
| WxCarCmdLog wxCarCmdLog = new WxCarCmdLog(); | WxCarCmdLog wxCarCmdLog = new WxCarCmdLog(); | ||||
| wxCarCmdLog.setVendorType(EnumCarVendor.CAR_ETCP.getCode()); | wxCarCmdLog.setVendorType(EnumCarVendor.CAR_ETCP.getCode()); | ||||
| wxCarCmdLog.setCmdType(EnumCarCmd.CAR_ETCP_CALLBACK_PARK_OUT.getCode()); | wxCarCmdLog.setCmdType(EnumCarCmd.CAR_ETCP_CALLBACK_PARK_OUT.getCode()); | ||||
| wxCarCmdLog.setCmdJson(JSON.toJSONString(paramMap)); | wxCarCmdLog.setCmdJson(JSON.toJSONString(paramMap)); | ||||
| wxCarCmdLog.setCreateDate(currentDate); | wxCarCmdLog.setCreateDate(currentDate); | ||||
| wxCarCmdLog.setUpdateDate(currentDate); | wxCarCmdLog.setUpdateDate(currentDate); | ||||
| String etcpParkId = paramMap.get(ETCPUtil.ETCP_PARK_ID); | |||||
| String tenantId = null; | |||||
| WxPark parkQ = new WxPark(); | |||||
| parkQ.setVendorType(EnumCarVendor.CAR_ETCP.getCode()); | |||||
| parkQ.setParkingId(etcpParkId); | |||||
| WxPark park = wxParkService.getByObj(parkQ); | |||||
| if (park == null) { | |||||
| logger.error("etcpParkOutCallback: ETCP车场未找到 " + etcpParkId); | |||||
| // return new Result(ErrorCode.CAR_PARK_NOT_FOUND.getCode(), "ETCP车场未找到"+ etcpParkId); | |||||
| } else { | |||||
| tenantId = park.getTenantId(); | |||||
| wxCarCmdLog.setTenantId(tenantId); | |||||
| } | |||||
| try { | try { | ||||
| wxCarCmdLogService.saveOrUpdate(wxCarCmdLog); | wxCarCmdLogService.saveOrUpdate(wxCarCmdLog); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error("tjdParkoutCallback: 入库错误" + paramMap.toString()); | |||||
| map.put("isSuccess", "0"); | |||||
| map.put("errorMsg", "入库错误" + paramMap.toString()); | |||||
| return map; | |||||
| logger.error("etcpParkOutCallback: 入库错误 " + e.getMessage() + "\n" + paramMap.toString()); | |||||
| return true; | |||||
| } | } | ||||
| map.put("isSuccess", "0"); | |||||
| map.put("errorMsg", ""); | |||||
| return map; | |||||
| } | |||||
| String synId = paramMap.get(ETCPUtil.ETCP_SYN_ID); | |||||
| String exitTime = paramMap.get(ETCPUtil.ETCP_EXIT_TIME); | |||||
| String stayedTime = paramMap.get(ETCPUtil.ETCP_STAYED_TIME); | |||||
| String carNumber = paramMap.get(ETCPUtil.ETCP_CAR_NUMBER); | |||||
| String parkId = paramMap.get(ETCPUtil.ETCP_PARK_ID); | |||||
| String parkName = paramMap.get(ETCPUtil.ETCP_PARK_NAME); | |||||
| String userType = paramMap.get(ETCPUtil.ETCP_USER_TYPE); | |||||
| String entranceTime = paramMap.get(ETCPUtil.ETCP_ENTRANCE_TIME); | |||||
| String fixParkingId = paramMap.get(ETCPUtil.ETCP_FIX_PARKING_ID); | |||||
| String remainingDays = paramMap.get(ETCPUtil.ETCP_REMAINING_DAYS); | |||||
| try { | |||||
| // 保存WxCarPayRecord | |||||
| WxCarPayRecord record = new WxCarPayRecord(); | |||||
| record.setSynId(synId); | |||||
| if(StringUtils.isNotBlank(exitTime)) { | |||||
| record.setExitTime(dateFormat.parse(exitTime)); | |||||
| } | |||||
| if(StringUtils.isNotBlank(stayedTime)) { | |||||
| record.setStayedTime(Long.parseLong(stayedTime)); | |||||
| } | |||||
| record.setVendorType(wxCarCmdLog.getVendorType()); | |||||
| record.setSynId(synId); | |||||
| record.setParkId(parkId); | |||||
| record.setParkName(parkName); | |||||
| record.setUserType(userType); | |||||
| record.setPlateNumber(carNumber); | |||||
| if(StringUtils.isNotBlank(entranceTime)) { | |||||
| record.setEntranceTime(dateFormat.parse(entranceTime)); | |||||
| } | |||||
| record.setFixParkingId(fixParkingId); | |||||
| record.setRemainingDays(remainingDays); | |||||
| //record.setPhone(phoneStrs); | |||||
| record.setTenantId(tenantId); | |||||
| WxCarPayRecord query = new WxCarPayRecord(); | |||||
| query.setSynId(synId); | |||||
| PageInfo<WxCarPayRecord> page = wxCarPayRecordService.findCarPayListByPage(query,1,1); | |||||
| if(page != null && CollectionUtils.isNotEmpty(page.getList())){ | |||||
| record.setId(page.getList().get(0).getId()); | |||||
| } | |||||
| wxCarPayRecordService.saveOrUpdate(record); | |||||
| } catch (Exception e) { | |||||
| logger.error("WxCarPayRecord: 出场更新错误 " +e.getMessage()+", " +paramMap.toString()); | |||||
| return true; | |||||
| } | |||||
| return false; | |||||
| } | |||||
| } | } | ||||
| @@ -0,0 +1,482 @@ | |||||
| package com.iformall.controller.callback; | |||||
| import com.alibaba.fastjson.JSON; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.*; | |||||
| import com.iformall.enums.EnumCarCmd; | |||||
| import com.iformall.enums.EnumCarVendor; | |||||
| import com.iformall.enums.EnumCouponSendSendType; | |||||
| import com.iformall.service.*; | |||||
| import com.iformall.utils.DateUtils; | |||||
| import com.iformall.utils.car.TJDUtil; | |||||
| import org.apache.commons.collections.CollectionUtils; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.RequestBody; | |||||
| import org.springframework.web.bind.annotation.RequestMapping; | |||||
| import org.springframework.web.bind.annotation.RestController; | |||||
| import java.text.SimpleDateFormat; | |||||
| import java.util.Date; | |||||
| import java.util.HashMap; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| @RestController | |||||
| @RequestMapping("/carCallback") | |||||
| public class WxCarTJDCallBackController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| WxParkService wxParkService; | |||||
| @Autowired | |||||
| WxCUserCarService wxCUserCarService; | |||||
| @Autowired | |||||
| WxMerchantService wxMerchantService; | |||||
| @Autowired | |||||
| WxCarCmdLogService wxCarCmdLogService; | |||||
| @Autowired | |||||
| WxCouponSendService wxCouponSendService; | |||||
| @Autowired | |||||
| WxCarPayRecordService wxCarPayRecordService; | |||||
| @Autowired | |||||
| WxCUserService wxCUserService; | |||||
| /** | |||||
| * 注册车牌 | |||||
| * @param paramMap | |||||
| * @return | |||||
| * { | |||||
| * "service": "parkhub.car.register", | |||||
| * "partner": "5836b8b51ada463ebc6199579f029566", "sign": "3347b109a1e44f3fd5baa78b74184948", "signType": "md5", | |||||
| * "charset": "utf-8", | |||||
| * "version": "1.0", | |||||
| * "timestamp": "2016-05-26 11:30:10", | |||||
| * "carNum": "京A12345", | |||||
| * "carNumColor": "blue", | |||||
| * "phone": "13612341234", | |||||
| * "outCarId": "432d85d7441316d29504f480e6a734a8" | |||||
| * } | |||||
| * { | |||||
| * "timestamp": "1464235239561", | |||||
| * "returnCode": "T", | |||||
| * "returnMsg": "OK", | |||||
| * "isSuccess": "0", | |||||
| * "errorMSG": "", | |||||
| * "carId": "11ce3dca34124e97830ad466e532eda7" | |||||
| * } | |||||
| */ | |||||
| @RequestMapping(value = "/tjdRegisterCallback") | |||||
| public Map tjdRegisterCallback(@RequestBody Map<String, String> paramMap) { | |||||
| Map map = new HashMap(); | |||||
| return map; | |||||
| } | |||||
| /** | |||||
| * 进场通知 | |||||
| * { | |||||
| * wLon=116.310335, | |||||
| * lon=116.316813, | |||||
| * outCarId=, | |||||
| * parkId=7715622dff834b34a44448b801c27607, | |||||
| * tradeId=e9e0d5db057f412fa323995fc292f6f7, | |||||
| * carNumColor=blue, | |||||
| * canFindCar=0, | |||||
| * miniProgram={ | |||||
| * "path": "pages/pre_pay/index/main", | |||||
| * "extraData": { | |||||
| * "prePayType": "16", | |||||
| * "channel": "30166", | |||||
| * "isShowDetail": "true", | |||||
| * "partnerId": "", | |||||
| * "orderId": "e9e0d5db057f412fa323995fc292f6f7"} | |||||
| * }, | |||||
| * city=北京市, | |||||
| * parkName=开发停车场25, | |||||
| * address=财智大厦23楼, | |||||
| * carNum=京YTJD01, | |||||
| * wLat=39.93609, | |||||
| * payUrl=https://prep.tingjiandan.com/tcweixin/letter/prePay/pagePayInPark?prePayType=16&channel=30166&isShowDetail=true&partnerId=&orderId=e9e0d5db057f412fa323995fc292f6f7&returnUrl=, | |||||
| * district=海淀区, | |||||
| * lat=39.942078, | |||||
| * inDt=20190920070500 | |||||
| * } | |||||
| */ | |||||
| @RequestMapping(value = "/tjdParkInCallback") | |||||
| public Map tjdParkInCallback(@RequestBody Map<String, String> paramMap) { | |||||
| logger.info("["+getIpAddr()+"tjdParkInCallback: " + paramMap.toString()); | |||||
| Map map = new HashMap(); | |||||
| Date currentDate = new Date(); | |||||
| String parkId = paramMap.get(TJDUtil.TJD_PARK_ID); | |||||
| String parkName = paramMap.get(TJDUtil.TJD_PARK_NAME); | |||||
| String carNumber = paramMap.get(TJDUtil.TJD_CAR_NUMBER); | |||||
| String tradeId = paramMap.get(TJDUtil.TJD_TRADE_ID); | |||||
| String inDt = paramMap.get(TJDUtil.TJD_IN_DT); | |||||
| WxCarCmdLog wxCarCmdLog = new WxCarCmdLog(); | |||||
| wxCarCmdLog.setVendorType(EnumCarVendor.CAR_TJD.getCode()); | |||||
| wxCarCmdLog.setCmdType(EnumCarCmd.CAR_TJD_CALLBACK_PARK_IN.getCode()); | |||||
| wxCarCmdLog.setCmdJson(JSON.toJSONString(paramMap)); | |||||
| wxCarCmdLog.setCreateDate(currentDate); | |||||
| wxCarCmdLog.setUpdateDate(currentDate); | |||||
| String tenantId = null; | |||||
| WxPark parkQ = new WxPark(); | |||||
| parkQ.setVendorType(EnumCarVendor.CAR_TJD.getCode()); | |||||
| parkQ.setParkId(parkId); | |||||
| WxPark park = wxParkService.getByObj(parkQ); | |||||
| if (park == null) { | |||||
| logger.error("tjdParkInCallback: 车场未找到" + parkId); | |||||
| map.put(TJDUtil.TJD_IS_SUC, TJDUtil.TJD_ERR_1); | |||||
| map.put(TJDUtil.TJD_ERR_MSG, "车场未找到" + parkId); | |||||
| return map; | |||||
| } else { | |||||
| tenantId = park.getTenantId(); | |||||
| wxCarCmdLog.setTenantId(park.getTenantId()); | |||||
| } | |||||
| try { | |||||
| wxCarCmdLogService.saveOrUpdate(wxCarCmdLog); | |||||
| } catch (Exception e) { | |||||
| logger.error("tjdParkInCallback: 入库错误" + paramMap.toString()); | |||||
| map.put(TJDUtil.TJD_IS_SUC, TJDUtil.TJD_ERR_2); | |||||
| map.put(TJDUtil.TJD_ERR_MSG, "入库错误" + paramMap.toString()); | |||||
| return map; | |||||
| } | |||||
| // 停车发券 | |||||
| String phoneStrs = ""; | |||||
| if (StringUtils.isNotBlank(carNumber)) { | |||||
| // 根据车牌查找用户 | |||||
| WxCUserCar userCarQ = new WxCUserCar(); | |||||
| userCarQ.setTenantId(tenantId); | |||||
| userCarQ.setCarNumber(carNumber); | |||||
| userCarQ.setVendorType(EnumCarVendor.CAR_ETCP.getCode()); | |||||
| // TODO 可能多用户关联同一张车牌 | |||||
| List<WxCUserCar> userCarList = wxCUserCarService.getList(userCarQ); | |||||
| boolean bFirst = true; | |||||
| for (WxCUserCar userCar : userCarList) { | |||||
| wxCouponSendService.sendCouponToUser(EnumCouponSendSendType.CAR_STOP, userCar); | |||||
| WxCUser cUser = wxCUserService.getById(userCar.getCUserId()); | |||||
| if(cUser != null){ | |||||
| if(bFirst) { | |||||
| phoneStrs = cUser.getPhone(); | |||||
| bFirst = false; | |||||
| } else { | |||||
| phoneStrs += "," + cUser.getPhone(); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| try { | |||||
| // 保存WxCarPayRecord | |||||
| WxCarPayRecord record = new WxCarPayRecord(); | |||||
| record.setTenantId(tenantId); | |||||
| record.setVendorType(wxCarCmdLog.getVendorType()); | |||||
| record.setSynId(tradeId); | |||||
| record.setParkId(parkId); | |||||
| record.setParkName(parkName); | |||||
| record.setPlateNumber(carNumber); | |||||
| if(StringUtils.isNotBlank(inDt)) { | |||||
| record.setEntranceTime(TJDUtil.dateOutFormat.parse(inDt)); | |||||
| } | |||||
| record.setPhone(phoneStrs); | |||||
| WxCarPayRecord query = new WxCarPayRecord(); | |||||
| query.setTenantId(tenantId); | |||||
| query.setParkId(parkId); | |||||
| query.setSynId(tradeId); | |||||
| PageInfo<WxCarPayRecord> page = wxCarPayRecordService.findCarPayListByPage(query,1,1); | |||||
| if(page != null && CollectionUtils.isNotEmpty(page.getList())){ | |||||
| record.setId(page.getList().get(0).getId()); | |||||
| } | |||||
| wxCarPayRecordService.saveOrUpdate(record); | |||||
| } catch (Exception e) { | |||||
| logger.error("WxCarPayRecord: 入库错误 "+e.getMessage()+"," + paramMap.toString()); | |||||
| } | |||||
| map.put(TJDUtil.TJD_IS_SUC, TJDUtil.TJD_SUC); | |||||
| return map; | |||||
| } | |||||
| /** | |||||
| * 离场通知 | |||||
| * { | |||||
| * "parkId": "f3f11a46f3a14056953aed97944242d4", | |||||
| * "parkName": "测试停车场", | |||||
| * "carNum": "京A12345", | |||||
| * "carNumColor ": "blue", | |||||
| * "tradeId": "5836b8b52ada463ebc6199579f029565", | |||||
| * "inDt": "20170319232020", | |||||
| * "outDt": "20170319232020", | |||||
| * "parkAmount": "5.20", | |||||
| * "lon": "74.000272", | |||||
| * "lat": "159.768703", | |||||
| * "wLon": "123.523032", | |||||
| * "wLat": "35.430735" | |||||
| * } | |||||
| */ | |||||
| @RequestMapping(value = "/tjdParkOutCallback") | |||||
| public Map tjdParkOutCallback(@RequestBody Map<String, String> paramMap) { | |||||
| logger.info("["+getIpAddr()+"tjdParkOutCallback: " + paramMap.toString()); | |||||
| Map map = new HashMap(); | |||||
| String parkId = paramMap.get(TJDUtil.TJD_PARK_ID); | |||||
| String parkName = paramMap.get(TJDUtil.TJD_PARK_NAME); | |||||
| String carNumber = paramMap.get(TJDUtil.TJD_CAR_NUMBER); | |||||
| String tradeId = paramMap.get(TJDUtil.TJD_TRADE_ID); | |||||
| String inDt = paramMap.get(TJDUtil.TJD_IN_DT); | |||||
| String outDt = paramMap.get(TJDUtil.TJD_OUT_DT); | |||||
| String stopFee = paramMap.get(TJDUtil.TJD_PARK_AMT); | |||||
| Date currentDate = new Date(); | |||||
| WxCarCmdLog wxCarCmdLog = new WxCarCmdLog(); | |||||
| wxCarCmdLog.setVendorType(EnumCarVendor.CAR_TJD.getCode()); | |||||
| wxCarCmdLog.setCmdType(EnumCarCmd.CAR_TJD_CALLBACK_PARK_OUT.getCode()); | |||||
| wxCarCmdLog.setCmdJson(JSON.toJSONString(paramMap)); | |||||
| wxCarCmdLog.setCreateDate(currentDate); | |||||
| wxCarCmdLog.setUpdateDate(currentDate); | |||||
| String tenantId = null; | |||||
| WxPark parkQ = new WxPark(); | |||||
| parkQ.setVendorType(EnumCarVendor.CAR_TJD.getCode()); | |||||
| parkQ.setParkId(parkId); | |||||
| WxPark park = wxParkService.getByObj(parkQ); | |||||
| if (park == null) { | |||||
| logger.error("tjdParkOutCallback: 车场未找到" + parkId); | |||||
| map.put(TJDUtil.TJD_IS_SUC, TJDUtil.TJD_ERR_1); | |||||
| map.put(TJDUtil.TJD_ERR_MSG, "车场未找到" + parkId); | |||||
| return map; | |||||
| } else { | |||||
| tenantId = park.getTenantId(); | |||||
| wxCarCmdLog.setTenantId(tenantId); | |||||
| } | |||||
| try { | |||||
| wxCarCmdLogService.saveOrUpdate(wxCarCmdLog); | |||||
| } catch (Exception e) { | |||||
| logger.error("tjdParkOutCallback: 入库错误" + paramMap.toString()); | |||||
| map.put(TJDUtil.TJD_IS_SUC, TJDUtil.TJD_ERR_2); | |||||
| map.put(TJDUtil.TJD_ERR_MSG, "入库错误" + paramMap.toString()); | |||||
| return map; | |||||
| } | |||||
| try { | |||||
| // 保存WxCarPayRecord | |||||
| WxCarPayRecord record = new WxCarPayRecord(); | |||||
| record.setTenantId(tenantId); | |||||
| record.setVendorType(wxCarCmdLog.getVendorType()); | |||||
| record.setParkId(parkId); | |||||
| record.setParkName(parkName); | |||||
| record.setPlateNumber(carNumber); | |||||
| record.setSynId(tradeId); | |||||
| if(StringUtils.isNotBlank(inDt)) { | |||||
| record.setEntranceTime(TJDUtil.dateOutFormat.parse(inDt)); | |||||
| } | |||||
| if(StringUtils.isNotBlank(outDt)) { | |||||
| record.setExitTime(TJDUtil.dateOutFormat.parse(outDt)); | |||||
| Long stayedTime = (record.getExitTime().getTime() - record.getEntranceTime().getTime())/ 1000; | |||||
| record.setStayedTime(stayedTime); | |||||
| } | |||||
| if (StringUtils.isNotBlank(stopFee)) { | |||||
| record.setFee(stopFee); | |||||
| } | |||||
| WxCarPayRecord query = new WxCarPayRecord(); | |||||
| query.setTenantId(tenantId); | |||||
| query.setParkId(parkId); | |||||
| query.setSynId(tradeId); | |||||
| PageInfo<WxCarPayRecord> page = wxCarPayRecordService.findCarPayListByPage(query,1,1); | |||||
| if(page != null && CollectionUtils.isNotEmpty(page.getList())){ | |||||
| record.setId(page.getList().get(0).getId()); | |||||
| } | |||||
| wxCarPayRecordService.saveOrUpdate(record); | |||||
| } catch (Exception e) { | |||||
| logger.error("WxCarPayRecord: 出场更新错误 " +e.getMessage()+", " +paramMap.toString()); | |||||
| } | |||||
| map.put(TJDUtil.TJD_IS_SUC, TJDUtil.TJD_SUC); | |||||
| return map; | |||||
| } | |||||
| /** | |||||
| * 支付通知 | |||||
| * { | |||||
| * "parkId ": "77a3424e06e64248b4cf9e490c8c682d", | |||||
| * "parkName ": "测试停车场", | |||||
| * "carNum": "京A12345", | |||||
| * "carNumColor": "blue", | |||||
| * "tradeId": "6d697f7579724345881633a00ed3a671", | |||||
| * "payAmount": "5.00", | |||||
| * "payDt": "20180516225701", | |||||
| * "lon": "74.000272", | |||||
| * "lat": "159.768703", | |||||
| * "wLon": "123.523032", | |||||
| * "wLat": "35.430735" | |||||
| * } | |||||
| */ | |||||
| @RequestMapping(value = "/tjdPaidCallback") | |||||
| public Map tjdPaidCallback(@RequestBody Map<String, String> paramMap) { | |||||
| logger.info("["+getIpAddr()+"tjdPaidCallback: " + paramMap.toString()); | |||||
| Date currentDate = new Date(); | |||||
| Map map = new HashMap(); | |||||
| String parkId = paramMap.get(TJDUtil.TJD_PARK_ID); | |||||
| String parkName = paramMap.get(TJDUtil.TJD_PARK_NAME); | |||||
| String carNumber = paramMap.get(TJDUtil.TJD_CAR_NUMBER); | |||||
| String tradeId = paramMap.get(TJDUtil.TJD_TRADE_ID); | |||||
| String stopFee = paramMap.get(TJDUtil.TJD_PAY_AMT); | |||||
| String stopFeeTime = paramMap.get(TJDUtil.TJD_PAY_DT); | |||||
| WxCarCmdLog wxCarCmdLog = new WxCarCmdLog(); | |||||
| wxCarCmdLog.setVendorType(EnumCarVendor.CAR_ETCP.getCode()); | |||||
| wxCarCmdLog.setCmdType(EnumCarCmd.CAR_TJD_CALLBACK_PAID.getCode()); | |||||
| wxCarCmdLog.setCmdJson(JSON.toJSONString(paramMap)); | |||||
| wxCarCmdLog.setCreateDate(currentDate); | |||||
| wxCarCmdLog.setUpdateDate(currentDate); | |||||
| String tenantId = null; | |||||
| WxPark parkQ = new WxPark(); | |||||
| parkQ.setVendorType(EnumCarVendor.CAR_TJD.getCode()); | |||||
| parkQ.setParkId(parkId); | |||||
| WxPark park = wxParkService.getByObj(parkQ); | |||||
| if (park == null) { | |||||
| logger.error("tjdPaidCallback: 车场未找到" + parkId); | |||||
| map.put(TJDUtil.TJD_IS_SUC, TJDUtil.TJD_ERR_1); | |||||
| map.put(TJDUtil.TJD_ERR_MSG, "车场未找到" + parkId); | |||||
| return map; | |||||
| } else { | |||||
| tenantId = park.getTenantId(); | |||||
| wxCarCmdLog.setTenantId(tenantId); | |||||
| } | |||||
| try { | |||||
| wxCarCmdLogService.saveOrUpdate(wxCarCmdLog); | |||||
| } catch (Exception e) { | |||||
| logger.error("tjdPaidCallback: 入库错误" + paramMap.toString()); | |||||
| map.put(TJDUtil.TJD_IS_SUC, TJDUtil.TJD_ERR_2); | |||||
| map.put(TJDUtil.TJD_ERR_MSG, "入库错误" + paramMap.toString()); | |||||
| return map; | |||||
| } | |||||
| try { | |||||
| // 保存WxCarPayRecord | |||||
| WxCarPayRecord record = new WxCarPayRecord(); | |||||
| record.setTenantId(tenantId); | |||||
| record.setVendorType(wxCarCmdLog.getVendorType()); | |||||
| record.setParkId(parkId); | |||||
| record.setParkName(parkName); | |||||
| record.setPlateNumber(carNumber); | |||||
| record.setSynId(tradeId); | |||||
| record.setFee(stopFee); | |||||
| if (StringUtils.isNotBlank(stopFeeTime)) { | |||||
| record.setFeeTime(TJDUtil.dateOutFormat.parse(stopFeeTime)); | |||||
| } | |||||
| WxCarPayRecord query = new WxCarPayRecord(); | |||||
| record.setTenantId(tenantId); | |||||
| record.setParkId(parkId); | |||||
| record.setPlateNumber(carNumber); | |||||
| query.setSynId(tradeId); | |||||
| PageInfo<WxCarPayRecord> page = wxCarPayRecordService.findCarPayListByPage(query,1,2); | |||||
| if(page != null && page.getList().size() > 0){ | |||||
| if(page.getList().size() >= 2){ | |||||
| wxCarPayRecordService.saveOrUpdate(record); | |||||
| } else { | |||||
| WxCarPayRecord r = page.getList().get(0); | |||||
| if(r.getFeeTime() == null) { | |||||
| // 无缴费信息, 更新 | |||||
| record.setId(r.getId()); | |||||
| wxCarPayRecordService.saveOrUpdate(record); | |||||
| } else { | |||||
| // 缴费时间在15分钟以内,更新之前的数据, ETCP会把之前的缴费自动退款 | |||||
| if(DateUtils.isInDate15Mins(record.getFeeTime(), r.getFeeTime())) { | |||||
| record.setId(r.getId()); | |||||
| } | |||||
| wxCarPayRecordService.saveOrUpdate(record); | |||||
| } | |||||
| } | |||||
| } else { | |||||
| wxCarPayRecordService.saveOrUpdate(record); | |||||
| } | |||||
| } catch (Exception e) { | |||||
| logger.error("WxCarPayRecord: 缴费更新错误 " +e.getMessage()+", "+ paramMap.toString()); | |||||
| //return new Result(ErrorCode.DB_FAIL.getCode(), "入库错误" + paramMap.toString()); | |||||
| } | |||||
| map.put(TJDUtil.TJD_IS_SUC, TJDUtil.TJD_SUC); | |||||
| return map; | |||||
| } | |||||
| /** | |||||
| * 退款通知 (仅当接入方作为第一收款方时适用) | |||||
| * { | |||||
| * "parkId ": "77a3424e06e64248b4cf9e490c8c682d", | |||||
| * "parkName ": "测试停车场", | |||||
| * "carNum": "京A12345", | |||||
| * "carNumColor": "blue", | |||||
| * "tradeId": "6d697f7579724345881633a00ed3a671", | |||||
| * "payAmount": "5.00", | |||||
| * "payDt": "20180516225701", | |||||
| * "lon": "74.000272", | |||||
| * "lat": "159.768703", | |||||
| * "wLon": "123.523032", | |||||
| * "wLat": "35.430735" | |||||
| * } | |||||
| */ | |||||
| @RequestMapping(value = "/tjdRefundCallback") | |||||
| public Map tjdRefundCallback(@RequestBody Map<String, String> paramMap) { | |||||
| logger.info("["+getIpAddr()+"tjdRefundCallback: " + paramMap.toString()); | |||||
| Date currentDate = new Date(); | |||||
| Map map = new HashMap(); | |||||
| String tjdParkId = paramMap.get(TJDUtil.TJD_PARK_ID); | |||||
| String carNumber = paramMap.get(TJDUtil.TJD_CAR_NUMBER); | |||||
| String tradeId = paramMap.get(TJDUtil.TJD_TRADE_ID); | |||||
| WxCarCmdLog wxCarCmdLog = new WxCarCmdLog(); | |||||
| wxCarCmdLog.setVendorType(EnumCarVendor.CAR_ETCP.getCode()); | |||||
| wxCarCmdLog.setCmdType(EnumCarCmd.CAR_TJD_CALLBACK_REFUND.getCode()); | |||||
| wxCarCmdLog.setCmdJson(JSON.toJSONString(paramMap)); | |||||
| wxCarCmdLog.setCreateDate(currentDate); | |||||
| wxCarCmdLog.setUpdateDate(currentDate); | |||||
| String tenantId = null; | |||||
| WxPark parkQ = new WxPark(); | |||||
| parkQ.setVendorType(EnumCarVendor.CAR_TJD.getCode()); | |||||
| parkQ.setParkId(tjdParkId); | |||||
| WxPark park = wxParkService.getByObj(parkQ); | |||||
| if (park == null) { | |||||
| logger.error("tjdRefundCallback: 停简单车场未找到" + tjdParkId); | |||||
| map.put(TJDUtil.TJD_IS_SUC, TJDUtil.TJD_ERR_1); | |||||
| map.put(TJDUtil.TJD_ERR_MSG, "车场未找到" + tjdParkId); | |||||
| return map; | |||||
| } else { | |||||
| tenantId = park.getTenantId(); | |||||
| wxCarCmdLog.setTenantId(tenantId); | |||||
| } | |||||
| try { | |||||
| wxCarCmdLogService.saveOrUpdate(wxCarCmdLog); | |||||
| } catch (Exception e) { | |||||
| logger.error("tjdRefundCallback: 入库错误" + paramMap.toString()); | |||||
| map.put(TJDUtil.TJD_IS_SUC, TJDUtil.TJD_ERR_2); | |||||
| map.put(TJDUtil.TJD_ERR_MSG, "入库错误" + paramMap.toString()); | |||||
| return map; | |||||
| } | |||||
| map.put(TJDUtil.TJD_IS_SUC, TJDUtil.TJD_SUC); | |||||
| return map; | |||||
| } | |||||
| } | |||||
| @@ -219,8 +219,12 @@ public enum ErrorCode{ | |||||
| COUPON_PRESS_IS_OVERTIME(9071, "砍价已超时"), | COUPON_PRESS_IS_OVERTIME(9071, "砍价已超时"), | ||||
| COUPON_PRESS_IS_EXIST(9072, "此人已参与此次砍价"), | COUPON_PRESS_IS_EXIST(9072, "此人已参与此次砍价"), | ||||
| /** | |||||
| * 卡密 | |||||
| */ | |||||
| COUPON_PASSWORD_NOT_FOUND(9501, "兑换码未找到"), | |||||
| COUPON_PASSWORD_HAD_USED(9502, "兑换码已使用"), | |||||
| COUPON_PASSWORD_IS_CANCELED(9503, "兑换码已作废"), | |||||
| /** | /** | ||||
| * 微信 | * 微信 | ||||
| @@ -138,8 +138,12 @@ public class WxCoupon extends BaseEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value="领取条件",name="condition") | @io.swagger.annotations.ApiModelProperty(value="领取条件",name="condition") | ||||
| private String conditions; | private String conditions; | ||||
| @io.swagger.annotations.ApiModelProperty(value="最后一次审批操作类型,取值同EnumFlowKey",name="approvalType") | |||||
| private Integer approvalType; | private Integer approvalType; | ||||
| @io.swagger.annotations.ApiModelProperty(value="卡密是否支持(0:不支持,1支持)",name="passwordSupport") | |||||
| private Integer passwordSupport; | |||||
| @Transient | @Transient | ||||
| private String merchantParams; | private String merchantParams; | ||||
| @@ -162,7 +166,8 @@ public class WxCoupon extends BaseEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value="投放渠道id",name="couponChannelId") | @io.swagger.annotations.ApiModelProperty(value="投放渠道id",name="couponChannelId") | ||||
| private Long couponChannelId; | private Long couponChannelId; | ||||
| //营销分析 | |||||
| @Transient | |||||
| @io.swagger.annotations.ApiModelProperty(value="营销分析",name="wxCouponStatisVo") | |||||
| private WxCouponStatisVo wxCouponStatisVo; | private WxCouponStatisVo wxCouponStatisVo; | ||||
| @io.swagger.annotations.ApiModelProperty(value="投放审批状态",name="putApplyStatus") | @io.swagger.annotations.ApiModelProperty(value="投放审批状态",name="putApplyStatus") | ||||
| @@ -0,0 +1,57 @@ | |||||
| package com.iformall.domain.po; | |||||
| import cn.afterturn.easypoi.excel.annotation.Excel; | |||||
| import lombok.Data; | |||||
| import lombok.EqualsAndHashCode; | |||||
| import javax.persistence.Id; | |||||
| import javax.persistence.Table; | |||||
| import javax.persistence.Transient; | |||||
| import java.util.Date; | |||||
| import java.util.List; | |||||
| @Table(name = "wx_coupon_password") | |||||
| @Data | |||||
| @EqualsAndHashCode(callSuper = true) | |||||
| public class WxCouponPassword extends BaseEntity { | |||||
| @Id | |||||
| @Excel(name = "ID", width = 20, orderNum = "1") | |||||
| protected Long id; | |||||
| @Transient | |||||
| protected List<Long> ids; | |||||
| @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") | |||||
| private String tenantId; | |||||
| @io.swagger.annotations.ApiModelProperty(value="卡券ID",name="couponId") | |||||
| private Long couponId; | |||||
| @io.swagger.annotations.ApiModelProperty(value="卡券短ID",name="couponShort") | |||||
| private String couponShort; | |||||
| @Excel(name = "兑换码", width = 20, orderNum = "2") | |||||
| @io.swagger.annotations.ApiModelProperty(value="商户名称",name="password") | |||||
| private String password; | |||||
| @Excel(name = "状态", width = 20, replace = {"初始_0", "发送中_1", "已发出_2", "已使用_3", "不可用_4"}, orderNum = "4") | |||||
| @io.swagger.annotations.ApiModelProperty(value="卡密状态: 0初始1信息发出中2信息已发出3已使用4已过期",name="status") | |||||
| private Integer status; | |||||
| @Excel(name = "发送手机", width = 20, orderNum = "5") | |||||
| @io.swagger.annotations.ApiModelProperty(value="卡密发送到手机",name="sendedPhone") | |||||
| private String sendedPhone; | |||||
| @Excel(name = "会员卡号", width = 20, orderNum = "6") | |||||
| @io.swagger.annotations.ApiModelProperty(value="卡包ID(coupon_order_id/card_id)",name="cardId") | |||||
| private Long cardId; | |||||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | |||||
| private Date createDate; | |||||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | |||||
| private Date updateDate; | |||||
| @Excel(name="过期时间",width = 20,format="yyyy-MM-dd", orderNum = "3") | |||||
| @io.swagger.annotations.ApiModelProperty(value="过期时间",name="expireDate") | |||||
| private Date expireDate; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "发放ID", name = "presentId") | |||||
| private Long presentId; | |||||
| @Transient | |||||
| private String statusStr; | |||||
| } | |||||
| @@ -0,0 +1,47 @@ | |||||
| package com.iformall.domain.po; | |||||
| import io.swagger.annotations.ApiModelProperty; | |||||
| import lombok.Data; | |||||
| import lombok.EqualsAndHashCode; | |||||
| import javax.persistence.Id; | |||||
| import javax.persistence.Table; | |||||
| import javax.persistence.Transient; | |||||
| import java.util.Date; | |||||
| import java.util.List; | |||||
| @Table(name = "wx_coupon_present") | |||||
| @Data | |||||
| @EqualsAndHashCode(callSuper = true) | |||||
| public class WxCouponPresent extends BaseEntity { | |||||
| @Id | |||||
| protected Long id; | |||||
| @Transient | |||||
| protected List<Long> ids; | |||||
| @ApiModelProperty(value = "租户ID", name = "tenantId") | |||||
| private String tenantId; | |||||
| @ApiModelProperty(value = "用户ID", name = "userId") | |||||
| private Long userId; | |||||
| @ApiModelProperty(value = "卡券ID", name = "couponId") | |||||
| private Long couponId; | |||||
| @ApiModelProperty(value = "卡券名称", name = "couponName") | |||||
| private String couponName; | |||||
| @ApiModelProperty(value = "手机", name = "phones") | |||||
| private String phones; | |||||
| @ApiModelProperty(value = "创建时间", name = "createDate") | |||||
| private Date createTime; | |||||
| @ApiModelProperty(value = "更新时间", name = "updateDate") | |||||
| private Date updateTime; | |||||
| @ApiModelProperty(value = "发送数量", name = "sendAmount") | |||||
| private Integer sendAmount; | |||||
| @Transient | |||||
| protected Date sendTimeStart; | |||||
| @Transient | |||||
| protected Date sendTimeEnd; | |||||
| } | |||||
| @@ -49,4 +49,7 @@ public class WxMsgCallback extends BaseEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value="msgId",name="msgId") | @io.swagger.annotations.ApiModelProperty(value="msgId",name="msgId") | ||||
| private Long msgId; | private Long msgId; | ||||
| @io.swagger.annotations.ApiModelProperty(value = "业务ID", name = "businessId") | |||||
| private Long businessId; | |||||
| } | } | ||||
| @@ -0,0 +1,16 @@ | |||||
| package com.iformall.domain.vo; | |||||
| import lombok.Data; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| @Data | |||||
| public class WxCouponPasswordCountInfoVO { | |||||
| private Long couponId; | |||||
| private String couponName; | |||||
| private Long couponCount; | |||||
| private String price; | |||||
| } | |||||
| @@ -11,8 +11,11 @@ public enum EnumCarCmd { | |||||
| CAR_ETCP_CALLBACK_UNBIND(603, "ETCP车辆解绑通知"), | CAR_ETCP_CALLBACK_UNBIND(603, "ETCP车辆解绑通知"), | ||||
| CAR_ETCP_CALLBACK_PAY_MANUAL(604, "ETCP支付结果通知"), | CAR_ETCP_CALLBACK_PAY_MANUAL(604, "ETCP支付结果通知"), | ||||
| CAR_ETCP_CALLBACK_UNPAY(605, "ETCP停车费获取"), | CAR_ETCP_CALLBACK_UNPAY(605, "ETCP停车费获取"), | ||||
| CAR_TJD_CALLBACK_PARK_IN(610, "停简单入场通知"), | |||||
| CAR_TJD_CALLBACK_PARK_OUT(611, "停简单出场通知"), | |||||
| CAR_TJD_CALLBACK_REGISTER(610, "停简单注册车牌"), | |||||
| CAR_TJD_CALLBACK_PARK_IN(611, "停简单进场通知"), | |||||
| CAR_TJD_CALLBACK_PARK_OUT(612, "停简单离场通知"), | |||||
| CAR_TJD_CALLBACK_PAID(613, "停简单支付通知"), | |||||
| CAR_TJD_CALLBACK_REFUND(614, "停简单退款通知"), | |||||
| ; | ; | ||||
| public static EnumCarCmd getEnum(Integer code) { | public static EnumCarCmd getEnum(Integer code) { | ||||
| @@ -0,0 +1,39 @@ | |||||
| package com.iformall.enums; | |||||
| /** | |||||
| * Created by Stormeye on 2019/09/17. | |||||
| */ | |||||
| public enum EnumCouponPasswordStatus { | |||||
| INIT(0, "初始"), | |||||
| MSG_SENDING(1, "消息发送中"), | |||||
| MSG_SENDED(2, "消息已发送"), | |||||
| USED(3, "已使用"), | |||||
| CANCEL(4, "已作废"); | |||||
| public static EnumCouponPasswordStatus getEnum(Integer code) { | |||||
| for (EnumCouponPasswordStatus value : values()) { | |||||
| if (value.getCode().equals(code)) { | |||||
| return value; | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| private Integer code; | |||||
| private String message; | |||||
| EnumCouponPasswordStatus(Integer code, String message) { | |||||
| this.code = code; | |||||
| this.message = message; | |||||
| } | |||||
| public Integer getCode() { | |||||
| return code; | |||||
| } | |||||
| public String getMessage() { | |||||
| return message; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,36 @@ | |||||
| package com.iformall.enums; | |||||
| /** | |||||
| * Created by Stormeye on 2018/08/09. | |||||
| */ | |||||
| public enum EnumCouponPasswordSupport { | |||||
| NOT_SUPPORT(0, "不支持"), | |||||
| SUPPORTED(1, "支持"), | |||||
| ; | |||||
| public static EnumCouponPasswordSupport getEnum(Integer code) { | |||||
| for (EnumCouponPasswordSupport value : values()) { | |||||
| if (value.getCode().equals(code)) { | |||||
| return value; | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| private Integer code; | |||||
| private String message; | |||||
| EnumCouponPasswordSupport(Integer code, String message) { | |||||
| this.code = code; | |||||
| this.message = message; | |||||
| } | |||||
| public Integer getCode() { | |||||
| return code; | |||||
| } | |||||
| public String getMessage() { | |||||
| return message; | |||||
| } | |||||
| } | |||||
| @@ -34,6 +34,8 @@ public enum EnumMsgModel { | |||||
| //会员生日券 | //会员生日券 | ||||
| COUPON_BIRTHDAY_OPENED(28, "会员生日券倍率开启"), | COUPON_BIRTHDAY_OPENED(28, "会员生日券倍率开启"), | ||||
| COUPON_BIRTHDAY_OPENED_NO(29, "会员生日券倍率未开启"), | COUPON_BIRTHDAY_OPENED_NO(29, "会员生日券倍率未开启"), | ||||
| COUPON_CARD_SEND(30, "系统发卡"), | |||||
| ; | ; | ||||
| public static EnumMsgModel getEnum(Integer code) { | public static EnumMsgModel getEnum(Integer code) { | ||||
| @@ -44,5 +44,11 @@ public interface WxCUserBasicInfoMapper extends CommonMapper<WxCUserBasicInfo, S | |||||
| long findImportUserCount(WxCUserBasicInfoDto dto); | long findImportUserCount(WxCUserBasicInfoDto dto); | ||||
| void incActRecordById(Long id); | void incActRecordById(Long id); | ||||
| /** | |||||
| * 查找wx_c_user中不存在的用户 | |||||
| * @return | |||||
| */ | |||||
| List<WxCUserBasicInfo> selectNotCUserList(); | |||||
| } | } | ||||
| @@ -0,0 +1,24 @@ | |||||
| package com.iformall.mapper; | |||||
| import com.iformall.common.CommonMapper; | |||||
| import com.iformall.domain.po.WxCouponPassword; | |||||
| import com.iformall.domain.vo.WxCouponPasswordCountInfoVO; | |||||
| import java.util.List; | |||||
| public interface WxCouponPasswordMapper extends CommonMapper<WxCouponPassword, Long> { | |||||
| List<WxCouponPassword> findList(WxCouponPassword wxCouponPassword); | |||||
| List<WxCouponPassword> findAvaPasswordListByCouponId(WxCouponPassword wxCouponPassword); | |||||
| void insertCouponPasswds(List<WxCouponPassword> pwdlist); | |||||
| int disableByCouponId(Long couponId); | |||||
| int downloadByCouponId(Long couponId); | |||||
| List<WxCouponPassword> findCouponGroupList(WxCouponPassword wxCouponPassword); | |||||
| List<WxCouponPasswordCountInfoVO> findCouponCountInfo(WxCouponPassword wxCouponPassword); | |||||
| void updateStatus(List<WxCouponPassword> tempList); | |||||
| } | |||||
| @@ -0,0 +1,13 @@ | |||||
| package com.iformall.mapper; | |||||
| import com.iformall.common.CommonMapper; | |||||
| import com.iformall.domain.po.WxCouponPassword; | |||||
| import com.iformall.domain.po.WxCouponPresent; | |||||
| import java.util.List; | |||||
| public interface WxCouponPresentMapper extends CommonMapper<WxCouponPresent, Long> { | |||||
| List<WxCouponPresent> findList(WxCouponPresent wxCouponPresent); | |||||
| } | |||||
| @@ -4,6 +4,7 @@ import com.iformall.common.CommonMapper; | |||||
| import com.iformall.domain.po.WxCreditHistory; | import com.iformall.domain.po.WxCreditHistory; | ||||
| import com.iformall.domain.vo.WxCreditHistoryNewIdVo; | import com.iformall.domain.vo.WxCreditHistoryNewIdVo; | ||||
| import com.iformall.domain.vo.WxCreditHistoryVo; | import com.iformall.domain.vo.WxCreditHistoryVo; | ||||
| import org.apache.ibatis.annotations.Param; | |||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.List; | import java.util.List; | ||||
| @@ -29,6 +30,4 @@ public interface WxCreditHistoryMapper extends CommonMapper<WxCreditHistory, Lon | |||||
| long getDecrementCreditAmount(WxCreditHistory wxCreditHistory); | long getDecrementCreditAmount(WxCreditHistory wxCreditHistory); | ||||
| long getPeopleCount(WxCreditHistory wxCreditHistory); | long getPeopleCount(WxCreditHistory wxCreditHistory); | ||||
| List<WxCreditHistory> findListAfter(Integer creditType, String dateTime); | |||||
| } | } | ||||
| @@ -0,0 +1,78 @@ | |||||
| package com.iformall.service; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.WxCUser; | |||||
| import com.iformall.domain.po.WxCoupon; | |||||
| import com.iformall.domain.po.WxCouponPassword; | |||||
| import com.iformall.domain.po.WxOrder; | |||||
| import com.iformall.domain.vo.WxCouponPasswordCountInfoVO; | |||||
| import com.iformall.enums.EnumCouponPasswordStatus; | |||||
| import com.iformall.exception.MallinkException; | |||||
| import javax.servlet.http.HttpServletRequest; | |||||
| import javax.servlet.http.HttpServletResponse; | |||||
| import java.util.List; | |||||
| public interface WxCouponPasswordService { | |||||
| /** | |||||
| * 根据实体查询分页列表 | |||||
| * | |||||
| * @param record | |||||
| * @param pageIndex | |||||
| * @param pageSize | |||||
| * @return | |||||
| */ | |||||
| PageInfo<WxCouponPassword> listAsPage(WxCouponPassword record, Integer pageIndex, Integer pageSize); | |||||
| /** | |||||
| * 根据Id获得实体 | |||||
| * | |||||
| * @param id | |||||
| * @return | |||||
| */ | |||||
| WxCouponPassword getById(Long id); | |||||
| /** | |||||
| * 根据密码获取卡密信息 | |||||
| * | |||||
| * @param obj | |||||
| * @return | |||||
| */ | |||||
| WxCouponPassword getByObj(WxCouponPassword obj); | |||||
| /** | |||||
| * 保存或更新实体 | |||||
| * | |||||
| * @param record | |||||
| */ | |||||
| void saveOrUpdate(WxCouponPassword record); | |||||
| /** | |||||
| * 根据Id删除实体 | |||||
| * | |||||
| * @param id | |||||
| */ | |||||
| void deleteById(Long id); | |||||
| /** | |||||
| * 生产卡密 | |||||
| * @param tenantId | |||||
| * @param couponId | |||||
| * @param inventory | |||||
| */ | |||||
| void mkPasswords(String tenantId, Long couponId, Integer inventory); | |||||
| /** | |||||
| * 导出兑换码 | |||||
| * @param request | |||||
| * @param response | |||||
| * @param couponPassword | |||||
| */ | |||||
| void exportData(HttpServletRequest request, HttpServletResponse response, WxCouponPassword couponPassword); | |||||
| PageInfo<WxCouponPasswordCountInfoVO> findCouponList(WxCouponPassword wxCouponPassword, Integer pageNum, Integer pageSize); | |||||
| List<WxCouponPassword> findList(WxCouponPassword wxCouponPassword); | |||||
| } | |||||
| @@ -0,0 +1,23 @@ | |||||
| package com.iformall.service; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.WxCouponPassword; | |||||
| import com.iformall.domain.po.WxCouponPresent; | |||||
| import java.util.List; | |||||
| import java.util.Set; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| public interface WxCouponPresentService { | |||||
| PageInfo<WxCouponPresent> listAsPage(WxCouponPresent wxCouponPresent, Integer pageNum, Integer pageSize); | |||||
| WxCouponPresent findById(Long id); | |||||
| ResultData add(WxCouponPresent wxCouponPresent, List<WxCouponPassword> list, Set<String> phoneSet); | |||||
| } | |||||
| @@ -4,8 +4,6 @@ import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.WxMsgValidationcode; | import com.iformall.domain.po.WxMsgValidationcode; | ||||
| import java.util.Map; | |||||
| public interface WxMsgValidationcodeService { | public interface WxMsgValidationcodeService { | ||||
| /** | /** | ||||
| * 根据实体查询分页列表 | * 根据实体查询分页列表 | ||||
| @@ -44,6 +42,6 @@ public interface WxMsgValidationcodeService { | |||||
| ResultData hasvalidationcode(WxMsgValidationcode record); | ResultData hasvalidationcode(WxMsgValidationcode record); | ||||
| void addMsgCallback(WxMsgValidationcode wxmsg, String batchNo); | |||||
| void addMsgCallback(WxMsgValidationcode wxmsg, String batchNo, String id); | |||||
| } | } | ||||
| @@ -176,7 +176,7 @@ public interface WxOrderService { | |||||
| boolean checkCouponIsFree(WxCoupon coupon); | boolean checkCouponIsFree(WxCoupon coupon); | ||||
| // 2. 创建免费订单, 领取 couponOrder | // 2. 创建免费订单, 领取 couponOrder | ||||
| WxOrder saveFreeOrderForCoupon(WxCUser user, WxCoupon coupon, Long couponChannelId, String formId); | |||||
| WxOrder saveFreeOrderForCoupon(WxCUser user, WxCoupon coupon, Long couponChannelId, String formId, Long couponPasswordId); | |||||
| // 3. 创建有价订单 | // 3. 创建有价订单 | ||||
| WxOrder saveNoFreeOrderForCoupon(WxCUser user, WxCoupon coupon, Long couponChannelId, boolean isPress, Long orderGroupId, String formId); | WxOrder saveNoFreeOrderForCoupon(WxCUser user, WxCoupon coupon, Long couponChannelId, boolean isPress, Long orderGroupId, String formId); | ||||
| @@ -21,7 +21,6 @@ import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import java.util.*; | import java.util.*; | ||||
| import java.util.stream.Collectors; | |||||
| @Service | @Service | ||||
| public class WxCouponInjectServiceImpl implements WxCouponInjectService { | public class WxCouponInjectServiceImpl implements WxCouponInjectService { | ||||
| @@ -119,10 +118,12 @@ public class WxCouponInjectServiceImpl implements WxCouponInjectService { | |||||
| //2、通过标签 | //2、通过标签 | ||||
| String phones = record.getPhones(); | String phones = record.getPhones(); | ||||
| List<WxCUserBasicInfoFilterListDto> filter = record.getFilterList(); | List<WxCUserBasicInfoFilterListDto> filter = record.getFilterList(); | ||||
| if (!phones.isEmpty() && !filter.isEmpty()) {//两种方式只能选其一 | |||||
| if (!phones.isEmpty() && !filter.isEmpty()) { | |||||
| //两种方式只能选其一 | |||||
| return new ResultData(ErrorCode.MSG_SEND_WAY_CHOOSE_ERROR); | return new ResultData(ErrorCode.MSG_SEND_WAY_CHOOSE_ERROR); | ||||
| } | } | ||||
| if (phones.isEmpty() && filter.isEmpty()) {//两种方式必须选其一 | |||||
| if (phones.isEmpty() && filter.isEmpty()) { | |||||
| //两种方式必须选其一 | |||||
| return new ResultData(ErrorCode.MSG_SEND_WAY_CHOOSE_ERROR); | return new ResultData(ErrorCode.MSG_SEND_WAY_CHOOSE_ERROR); | ||||
| } | } | ||||
| @@ -0,0 +1,183 @@ | |||||
| package com.iformall.service.impl; | |||||
| import com.github.pagehelper.PageHelper; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.common.IdWorker; | |||||
| import com.iformall.domain.po.WxCouponPassword; | |||||
| import com.iformall.enums.EnumCouponPasswordStatus; | |||||
| import com.iformall.domain.vo.WxCouponPasswordCountInfoVO; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.mapper.WxCouponPasswordMapper; | |||||
| import com.iformall.service.ExcelService; | |||||
| import com.iformall.service.WxCouponPasswordService; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | |||||
| import javax.servlet.http.HttpServletRequest; | |||||
| import javax.servlet.http.HttpServletResponse; | |||||
| import java.util.ArrayList; | |||||
| import java.util.Date; | |||||
| import java.util.List; | |||||
| import java.util.Random; | |||||
| @Service | |||||
| public class WxCouponPasswordServiceImpl implements WxCouponPasswordService { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| WxCouponPasswordMapper wxCouponPasswordMapper; | |||||
| @Autowired | |||||
| ExcelService excelService; | |||||
| @Override | |||||
| public PageInfo<WxCouponPassword> listAsPage(WxCouponPassword record, Integer pageIndex, Integer pageSize) { | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponPasswordMapper.findList(record)); | |||||
| } | |||||
| @Override | |||||
| public WxCouponPassword getById(Long id) { | |||||
| return wxCouponPasswordMapper.selectByPrimaryKey(id); | |||||
| } | |||||
| @Override | |||||
| public WxCouponPassword getByObj(WxCouponPassword obj) { | |||||
| String errMsg = "兑换码已失效"; | |||||
| List<WxCouponPassword> pwdList = wxCouponPasswordMapper.findList(obj); | |||||
| if (pwdList.size() <= 0) { | |||||
| logger.error(ErrorCode.COUPON_PASSWORD_NOT_FOUND.getMessage()); | |||||
| throw new MallinkException(ErrorCode.COUPON_PASSWORD_NOT_FOUND.getCode(), errMsg); | |||||
| } | |||||
| WxCouponPassword password = null; | |||||
| Integer errCode = EnumCouponPasswordStatus.INIT.getCode(); | |||||
| for( WxCouponPassword pwd: pwdList) { | |||||
| if (pwd.getStatus().equals(EnumCouponPasswordStatus.USED.getCode())) { | |||||
| errCode = EnumCouponPasswordStatus.USED.getCode(); | |||||
| continue; | |||||
| } | |||||
| if (!pwd.getStatus().equals(EnumCouponPasswordStatus.USED.getCode()) && | |||||
| !pwd.getStatus().equals(EnumCouponPasswordStatus.CANCEL.getCode())) { | |||||
| password = pwd; | |||||
| } | |||||
| } | |||||
| if (password == null) { | |||||
| if (errCode.equals(EnumCouponPasswordStatus.USED.getCode())) { | |||||
| logger.error(ErrorCode.COUPON_PASSWORD_HAD_USED.getMessage()); | |||||
| throw new MallinkException(ErrorCode.COUPON_PASSWORD_HAD_USED.getCode(), errMsg); | |||||
| } else { | |||||
| logger.error(ErrorCode.COUPON_PASSWORD_IS_CANCELED.getMessage()); | |||||
| throw new MallinkException(ErrorCode.COUPON_PASSWORD_IS_CANCELED.getCode(), errMsg); | |||||
| } | |||||
| } | |||||
| return password; | |||||
| } | |||||
| @Override | |||||
| public void saveOrUpdate(WxCouponPassword record) { | |||||
| if (record.getId() == null) { | |||||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| record.setId(idWorker.nextId()); | |||||
| wxCouponPasswordMapper.insertSelective(record); | |||||
| } else { | |||||
| wxCouponPasswordMapper.updateByPrimaryKeySelective(record); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void deleteById(Long id) { | |||||
| wxCouponPasswordMapper.deleteByPrimaryKey(id); | |||||
| } | |||||
| @Override | |||||
| public void mkPasswords(String tenantId, Long couponId, Integer inventory) { | |||||
| String strAll = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; | |||||
| // 1.获取 coupon short 1 | |||||
| int couponShort = 0; | |||||
| String couponShortStr = "0"; | |||||
| WxCouponPassword pwQ = new WxCouponPassword(); | |||||
| pwQ.setTenantId(tenantId); | |||||
| List<WxCouponPassword> pwgList = wxCouponPasswordMapper.findCouponGroupList(pwQ); | |||||
| couponShort = pwgList.size(); | |||||
| couponShortStr = String.valueOf(strAll.charAt(couponShort)); | |||||
| // 2.随机字符 | |||||
| Random rand = new Random(); | |||||
| List<String> pwList = new ArrayList<>(); | |||||
| while (true) { | |||||
| StringBuilder sb = new StringBuilder(); | |||||
| for (int j = 0; j < 9; j++) { | |||||
| int f = (int) (Math.random() * 62); | |||||
| sb.append(strAll.charAt(f)); | |||||
| if (j == 4) { | |||||
| sb.append(couponShortStr); | |||||
| } | |||||
| } | |||||
| String pwd = sb.toString(); | |||||
| if (!pwList.stream().anyMatch(oPwd->oPwd.equals(pwd))) { | |||||
| pwList.add(pwd); | |||||
| } else { | |||||
| continue; | |||||
| } | |||||
| if (pwList.size() >= inventory) { | |||||
| break; | |||||
| } | |||||
| } | |||||
| // 3. save to db | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| Date curDate = new Date(); | |||||
| List<WxCouponPassword> couponPasswords = new ArrayList<>(); | |||||
| for (int i=0;i<pwList.size();i++) { | |||||
| WxCouponPassword newOne = new WxCouponPassword(); | |||||
| newOne.setId(idWorker.nextId()); | |||||
| newOne.setTenantId(tenantId); | |||||
| newOne.setCouponId(couponId); | |||||
| newOne.setCouponShort(couponShortStr); | |||||
| newOne.setPassword(pwList.get(i)); | |||||
| newOne.setStatus(EnumCouponPasswordStatus.INIT.getCode()); | |||||
| newOne.setCreateDate(curDate); | |||||
| newOne.setUpdateDate(curDate); | |||||
| couponPasswords.add(newOne); | |||||
| } | |||||
| wxCouponPasswordMapper.insertCouponPasswds(couponPasswords); | |||||
| } | |||||
| @Override | |||||
| public void exportData(HttpServletRequest request, HttpServletResponse response, WxCouponPassword couponPassword) { | |||||
| if (couponPassword.getCouponId() != null) { | |||||
| wxCouponPasswordMapper.downloadByCouponId(couponPassword.getCouponId()); | |||||
| } | |||||
| List<WxCouponPassword> pwdList = wxCouponPasswordMapper.findAvaPasswordListByCouponId(couponPassword); | |||||
| excelService.exportExcel(pwdList, null, "兑换码", WxCouponPassword.class, "卡兑换码.xlsx", response, false); | |||||
| } | |||||
| @Override | |||||
| public PageInfo<WxCouponPasswordCountInfoVO> findCouponList(WxCouponPassword record, Integer pageIndex, Integer pageSize) { | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponPasswordMapper.findCouponCountInfo(record)); | |||||
| } | |||||
| @Override | |||||
| public List<WxCouponPassword> findList(WxCouponPassword wxCouponPassword) { | |||||
| return wxCouponPasswordMapper.findList(wxCouponPassword); | |||||
| } | |||||
| /* | |||||
| public static void main(String[] args) { | |||||
| WxCouponPasswordServiceImpl ll = new WxCouponPasswordServiceImpl(); | |||||
| long startTime = System.currentTimeMillis(); | |||||
| System.out.println(startTime); | |||||
| ll.mkPasswords("456", 12345L, 100); | |||||
| long endTime = System.currentTimeMillis(); | |||||
| System.out.println(endTime); | |||||
| long usedTime = (endTime-startTime)/1000; | |||||
| System.out.println("耗时:" + usedTime + "s"); | |||||
| } | |||||
| */ | |||||
| } | |||||
| @@ -0,0 +1,107 @@ | |||||
| package com.iformall.service.impl; | |||||
| import com.github.pagehelper.PageHelper; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.common.IdWorker; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.WxAppinfo; | |||||
| import com.iformall.domain.po.WxCouponPassword; | |||||
| import com.iformall.domain.po.WxCouponPresent; | |||||
| import com.iformall.domain.po.msg.WxMsgRecord; | |||||
| import com.iformall.enums.*; | |||||
| import com.iformall.mapper.WxCouponPasswordMapper; | |||||
| import com.iformall.mapper.WxCouponPresentMapper; | |||||
| import com.iformall.mq.MqBaseProducer; | |||||
| import com.iformall.service.WxAppinfoService; | |||||
| import com.iformall.service.WxCouponPresentService; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.scheduling.annotation.Async; | |||||
| import org.springframework.stereotype.Service; | |||||
| import java.util.*; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| @Service | |||||
| public class WxCouponPresentServiceImpl implements WxCouponPresentService { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| WxCouponPresentMapper wxCouponPresentMapper; | |||||
| @Autowired | |||||
| WxCouponPasswordMapper wxCouponPasswordMapper; | |||||
| @Autowired | |||||
| WxAppinfoService wxAppinfoService; | |||||
| @Autowired | |||||
| private MqBaseProducer mqBaseProducer; | |||||
| @Override | |||||
| public PageInfo<WxCouponPresent> listAsPage(WxCouponPresent record, Integer pageIndex, Integer pageSize) { | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponPresentMapper.findList(record)); | |||||
| } | |||||
| @Override | |||||
| public WxCouponPresent findById(Long id) { | |||||
| return wxCouponPresentMapper.selectByPrimaryKey(id); | |||||
| } | |||||
| @Async | |||||
| @Override | |||||
| public ResultData add(WxCouponPresent record, List<WxCouponPassword> list, Set<String> phoneSet) { | |||||
| String tenantId = record.getTenantId(); | |||||
| //添加记录 | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| long id = idWorker.nextId(); | |||||
| record.setId(id); | |||||
| record.setSendAmount(phoneSet.size()); | |||||
| wxCouponPresentMapper.insertSelective(record); | |||||
| //小程序 | |||||
| WxAppinfo appInfo = wxAppinfoService.getCAppInfo(tenantId); | |||||
| String title = record.getCouponName(); | |||||
| String name = appInfo.getName(); | |||||
| List<WxCouponPassword> tempList = new ArrayList<>(); | |||||
| //循环发送 | |||||
| int i = 0; | |||||
| for (String phone : phoneSet) { | |||||
| WxCouponPassword couponPassword = list.get(i); | |||||
| //发送 | |||||
| sendMsg(tenantId, phone, title, name, couponPassword.getPassword(), couponPassword.getId().toString()); | |||||
| //记录发送数据便于更新状态 | |||||
| couponPassword.setPresentId(id); | |||||
| couponPassword.setSendedPhone(phone); | |||||
| tempList.add(couponPassword); | |||||
| i++; | |||||
| } | |||||
| //修改状态 | |||||
| wxCouponPasswordMapper.updateStatus(tempList); | |||||
| return new ResultData(); | |||||
| } | |||||
| private void sendMsg(String tenantId, String phone, String title, String appName, String password, String id) { | |||||
| logger.info("》》》》》》》》》》》"); | |||||
| logger.info("系统发卡发送短信开始"); | |||||
| logger.info("》》》》》》》》》》》"); | |||||
| Map<String, String> msgReplaceMap = new HashMap(); | |||||
| msgReplaceMap.put("id", id); | |||||
| msgReplaceMap.put("app", appName); | |||||
| msgReplaceMap.put("title", title); | |||||
| msgReplaceMap.put("pw", password); | |||||
| WxMsgRecord wxMsgRecord = new WxMsgRecord(); | |||||
| wxMsgRecord.setMsgType(EnumMsgRecordType.SMS.getCode()); | |||||
| wxMsgRecord.setModelType(EnumMsgModel.COUPON_CARD_SEND.getCode()); | |||||
| wxMsgRecord.setReceiver(phone); | |||||
| wxMsgRecord.setTenantId(tenantId); | |||||
| wxMsgRecord.setDynamicContentMap(msgReplaceMap); | |||||
| mqBaseProducer.sendMessage(wxMsgRecord, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||||
| logger.info("》》》》》》》》》》》"); | |||||
| logger.info("系统发卡发送短信结束"); | |||||
| logger.info("》》》》》》》》》》》"); | |||||
| } | |||||
| } | |||||
| @@ -14,7 +14,6 @@ import com.iformall.domain.vo.WxCouponCVo; | |||||
| import com.iformall.domain.vo.WxCouponStatisVo; | import com.iformall.domain.vo.WxCouponStatisVo; | ||||
| import com.iformall.domain.vo.WxMerchantVo; | import com.iformall.domain.vo.WxMerchantVo; | ||||
| import com.iformall.enums.*; | import com.iformall.enums.*; | ||||
| import com.iformall.exception.BizMessageException; | |||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.mapper.*; | import com.iformall.mapper.*; | ||||
| import com.iformall.service.*; | import com.iformall.service.*; | ||||
| @@ -34,7 +33,7 @@ import java.util.stream.Collectors; | |||||
| @Service | @Service | ||||
| public class WxCouponServiceImpl implements WxCouponService { | |||||
| public class WxCouponServiceImpl implements WxCouponService { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
| @Autowired | @Autowired | ||||
| @@ -64,6 +63,12 @@ import java.util.stream.Collectors; | |||||
| @Autowired | @Autowired | ||||
| WxCardInfoMapper wxCardInfoMapper; | WxCardInfoMapper wxCardInfoMapper; | ||||
| @Autowired | |||||
| WxCouponPasswordMapper couponPasswordMapper; | |||||
| @Autowired | |||||
| WxCouponPasswordService couponPasswordService; | |||||
| @Override | @Override | ||||
| public ResultData list(WxCoupon wxCoupon, Integer pageNum, Integer pageSize) { | public ResultData list(WxCoupon wxCoupon, Integer pageNum, Integer pageSize) { | ||||
| if (null == wxCoupon) wxCoupon = new WxCoupon(); | if (null == wxCoupon) wxCoupon = new WxCoupon(); | ||||
| @@ -326,6 +331,11 @@ import java.util.stream.Collectors; | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | ||||
| } | } | ||||
| if (record.getPasswordSupport() != null && record.getPasswordSupport().equals(EnumCouponPasswordSupport.SUPPORTED.getCode())) { | |||||
| // 如果用户启用卡密,生成数据并保存 | |||||
| couponPasswordService.mkPasswords(record.getTenantId(), record.getId(), record.getInventory()); | |||||
| } | |||||
| record.setCreateDate(new Date()); | record.setCreateDate(new Date()); | ||||
| record.setUpdateDate(new Date()); | record.setUpdateDate(new Date()); | ||||
| wxCouponMapper.insertSelective(record); | wxCouponMapper.insertSelective(record); | ||||
| @@ -408,9 +418,10 @@ import java.util.stream.Collectors; | |||||
| wxScreenAdService.updateStatusByCouponId(record.getId(), record.getTenantId(), EnumScreenAdStatus.INVALID.getCode()); | wxScreenAdService.updateStatusByCouponId(record.getId(), record.getTenantId(), EnumScreenAdStatus.INVALID.getCode()); | ||||
| //下架拼团券 | //下架拼团券 | ||||
| wxOrderService.updateOrderGroupStatusByCouponId(record.getId(), record.getTenantId(), EnumOrderStatus.ORDER_STATUS_COOPERATING_CANCEL.getCode()); | wxOrderService.updateOrderGroupStatusByCouponId(record.getId(), record.getTenantId(), EnumOrderStatus.ORDER_STATUS_COOPERATING_CANCEL.getCode()); | ||||
| //修改卡状态 | |||||
| // 卡下架后,转赠找不到卡相关信息,所以修改卡转赠状态为不可转赠 | |||||
| wxCardInfoMapper.updateTransferStatusByCouponId(record.getId()); | wxCardInfoMapper.updateTransferStatusByCouponId(record.getId()); | ||||
| // 卡券下架,未使用的卡密要下架 | |||||
| couponPasswordMapper.disableByCouponId(record.getId()); | |||||
| } | } | ||||
| record.setUpdateDate(new Date()); | record.setUpdateDate(new Date()); | ||||
| wxCouponMapper.updateByPrimaryKeySelective(record); | wxCouponMapper.updateByPrimaryKeySelective(record); | ||||
| @@ -4,10 +4,8 @@ import com.alibaba.fastjson.JSONArray; | |||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.common.IdWorker; | import com.iformall.common.IdWorker; | ||||
| import com.iformall.domain.po.WxMsgCallback; | |||||
| import com.iformall.domain.po.WxMsgConfig; | |||||
| import com.iformall.domain.po.WxMsgModel; | |||||
| import com.iformall.domain.po.WxMsgValidationcodeModel; | |||||
| import com.iformall.domain.po.*; | |||||
| import com.iformall.enums.EnumCouponPasswordStatus; | |||||
| import com.iformall.enums.EnumMsgSendStatus; | import com.iformall.enums.EnumMsgSendStatus; | ||||
| import com.iformall.mapper.*; | import com.iformall.mapper.*; | ||||
| import com.iformall.service.WxMsgCallbackService; | import com.iformall.service.WxMsgCallbackService; | ||||
| @@ -38,6 +36,9 @@ public class WxMsgCallbackServiceImpl implements WxMsgCallbackService { | |||||
| @Autowired | @Autowired | ||||
| WxMsgMapper wxMsgMapper; | WxMsgMapper wxMsgMapper; | ||||
| @Autowired | |||||
| WxCouponPasswordMapper wxCouponPasswordMapper; | |||||
| @Override | @Override | ||||
| public PageInfo<WxMsgCallback> listAsPage(WxMsgCallback record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxMsgCallback> listAsPage(WxMsgCallback record, Integer pageIndex, Integer pageSize) { | ||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxMsgCallbackMapper.findList(record)); | return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxMsgCallbackMapper.findList(record)); | ||||
| @@ -75,11 +76,11 @@ public class WxMsgCallbackServiceImpl implements WxMsgCallbackService { | |||||
| List<WxMsgCallback> wxMsgCallbacks = JSONArray.parseArray(param.get("item"), WxMsgCallback.class); | List<WxMsgCallback> wxMsgCallbacks = JSONArray.parseArray(param.get("item"), WxMsgCallback.class); | ||||
| wxMsgConfig = list.get(0); | wxMsgConfig = list.get(0); | ||||
| wxMsgConfig.setRemains(wxMsgConfig.getRemains() - wxMsgCallbacks.size()); | wxMsgConfig.setRemains(wxMsgConfig.getRemains() - wxMsgCallbacks.size()); | ||||
| //wxMsgConfigMapper.updateByPrimaryKeySelective(wxMsgConfig); | |||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| for (WxMsgCallback wxMsgCallback : wxMsgCallbacks) { | for (WxMsgCallback wxMsgCallback : wxMsgCallbacks) { | ||||
| WxMsgCallback callback=wxMsgCallbackMapper.queryCallbackByBatchNoAndPhone(wxMsgCallback); | WxMsgCallback callback=wxMsgCallbackMapper.queryCallbackByBatchNoAndPhone(wxMsgCallback); | ||||
| if(callback!=null){//有更新,无插入 | |||||
| if (callback != null) { | |||||
| //有更新,无插入 | |||||
| callback.setSign(param.get("sign")); | callback.setSign(param.get("sign")); | ||||
| callback.setTenantId(tenantId); | callback.setTenantId(tenantId); | ||||
| if (!wxMsgCallback.getStatus().equals(EnumMsgSendStatus.MSG_SEND_SUCCESS.getCode())) { | if (!wxMsgCallback.getStatus().equals(EnumMsgSendStatus.MSG_SEND_SUCCESS.getCode())) { | ||||
| @@ -93,6 +94,14 @@ public class WxMsgCallbackServiceImpl implements WxMsgCallbackService { | |||||
| callback.setCallbackId(wxMsgCallback.getId()); | callback.setCallbackId(wxMsgCallback.getId()); | ||||
| callback.setUpdatetime(new Date()); | callback.setUpdatetime(new Date()); | ||||
| wxMsgCallbackMapper.updateByPrimaryKeySelective(callback); | wxMsgCallbackMapper.updateByPrimaryKeySelective(callback); | ||||
| //更新业务 | |||||
| if (!callback.getBusinessId().equals(0L)) { | |||||
| WxCouponPassword couponPassword = new WxCouponPassword(); | |||||
| couponPassword.setId(callback.getBusinessId()); | |||||
| couponPassword.setStatus(EnumCouponPasswordStatus.MSG_SENDED.getCode()); | |||||
| couponPassword.setUpdateDate(new Date()); | |||||
| wxCouponPasswordMapper.updateByPrimaryKeySelective(couponPassword); | |||||
| } | |||||
| }else{ | }else{ | ||||
| Long callbackId = wxMsgCallback.getId(); | Long callbackId = wxMsgCallback.getId(); | ||||
| wxMsgCallback.setId(idWorker.nextId()); | wxMsgCallback.setId(idWorker.nextId()); | ||||
| @@ -14,6 +14,7 @@ import com.iformall.mq.MqBaseProducer; | |||||
| import com.iformall.service.WxMsgValidationcodeService; | import com.iformall.service.WxMsgValidationcodeService; | ||||
| import com.iformall.utils.DateUtils; | import com.iformall.utils.DateUtils; | ||||
| import org.apache.commons.collections.map.HashedMap; | import org.apache.commons.collections.map.HashedMap; | ||||
| import org.apache.commons.lang3.StringUtils; | |||||
| 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; | ||||
| @@ -113,7 +114,7 @@ public class WxMsgValidationcodeServiceImpl implements WxMsgValidationcodeServic | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void addMsgCallback(WxMsgValidationcode wxmsg, String batchNo){ | |||||
| public void addMsgCallback(WxMsgValidationcode wxmsg, String batchNo, String id) { | |||||
| logger.info("验证码发送时主动添加回调记录开始..."); | logger.info("验证码发送时主动添加回调记录开始..."); | ||||
| String phone = wxmsg.getPhone(); | String phone = wxmsg.getPhone(); | ||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| @@ -125,6 +126,9 @@ public class WxMsgValidationcodeServiceImpl implements WxMsgValidationcodeServic | |||||
| wxMsgCallback.setMsgId(wxmsg.getId()); | wxMsgCallback.setMsgId(wxmsg.getId()); | ||||
| wxMsgCallback.setStatus(EnumMsgSendStatus.MSG_SEND_FAIL.getCode()); | wxMsgCallback.setStatus(EnumMsgSendStatus.MSG_SEND_FAIL.getCode()); | ||||
| wxMsgCallback.setCreatetime(new Date()); | wxMsgCallback.setCreatetime(new Date()); | ||||
| if (StringUtils.isNotEmpty(id)) { | |||||
| wxMsgCallback.setBusinessId(Long.parseLong(id)); | |||||
| } | |||||
| wxMsgCallbackMapper.insertSelective(wxMsgCallback); | wxMsgCallbackMapper.insertSelective(wxMsgCallback); | ||||
| logger.info("验证码发送时主动添加回调记录结束..."); | logger.info("验证码发送时主动添加回调记录结束..."); | ||||
| } | } | ||||
| @@ -118,6 +118,9 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| @Autowired | @Autowired | ||||
| private WxMsgLimitService wxMsgLimitService; | private WxMsgLimitService wxMsgLimitService; | ||||
| @Autowired | |||||
| private WxCouponPasswordMapper couponPasswordMapper; | |||||
| @Override | @Override | ||||
| public PageInfo<WxOrder> listAsPage(WxOrder record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxOrder> listAsPage(WxOrder record, Integer pageIndex, Integer pageSize) { | ||||
| @@ -636,7 +639,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| * @param order | * @param order | ||||
| * @param coupon | * @param coupon | ||||
| */ | */ | ||||
| private WxCouponOrder createCouponOrder(WxOrder order, WxCUser user, WxCoupon coupon) { | |||||
| private WxCouponOrder createCouponOrder(WxOrder order, WxCUser user, WxCoupon coupon, Long couponPasswordId) { | |||||
| Date curr = new Date(); | Date curr = new Date(); | ||||
| Date valid_date = null; | Date valid_date = null; | ||||
| int limit_days = Constant.WX_LIMIT_DAYS; | int limit_days = Constant.WX_LIMIT_DAYS; | ||||
| @@ -720,6 +723,13 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| cardInfo.setShareFeeAmount(0); | cardInfo.setShareFeeAmount(0); | ||||
| cardInfo.setRemainingShareFeeAmount(0); | cardInfo.setRemainingShareFeeAmount(0); | ||||
| cardInfo.setRateAmount(0); | cardInfo.setRateAmount(0); | ||||
| if (coupon.getPasswordSupport().equals(EnumCouponPasswordSupport.SUPPORTED.getCode())) { | |||||
| WxCouponPassword updateCPwd = new WxCouponPassword(); | |||||
| updateCPwd.setId(couponPasswordId); | |||||
| updateCPwd.setCardId(cardInfo.getId()); | |||||
| updateCPwd.setStatus(EnumCouponPasswordStatus.USED.getCode()); | |||||
| couponPasswordMapper.updateByPrimaryKeySelective(updateCPwd); | |||||
| } | |||||
| } | } | ||||
| cardInfo.setServiceFeeAmount(fee); | cardInfo.setServiceFeeAmount(fee); | ||||
| @@ -812,7 +822,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| // 创建couponOrder | // 创建couponOrder | ||||
| WxCouponOrder couponOrder = null; | WxCouponOrder couponOrder = null; | ||||
| try { | try { | ||||
| couponOrder = createCouponOrder(record, user, coupon); | |||||
| couponOrder = createCouponOrder(record, user, coupon, null); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error("保存订单:" + e.getMessage()); | logger.error("保存订单:" + e.getMessage()); | ||||
| throw new MallinkException(ErrorCode.COUPON_ORDER_SAVE_ERR.getCode(), coupon.getTitle() + ErrorCode.COUPON_ORDER_SAVE_ERR.getMessage()); | throw new MallinkException(ErrorCode.COUPON_ORDER_SAVE_ERR.getCode(), coupon.getTitle() + ErrorCode.COUPON_ORDER_SAVE_ERR.getMessage()); | ||||
| @@ -859,7 +869,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| // 创建couponOrder | // 创建couponOrder | ||||
| try { | try { | ||||
| createCouponOrder(updateOrder, user, coupon); | |||||
| createCouponOrder(updateOrder, user, coupon, null); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error("创建券包:" + e.getMessage()); | logger.error("创建券包:" + e.getMessage()); | ||||
| throw new MallinkException(ErrorCode.COUPON_ORDER_SAVE_ERR); | throw new MallinkException(ErrorCode.COUPON_ORDER_SAVE_ERR); | ||||
| @@ -1360,7 +1370,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| WxOrder order = null; | WxOrder order = null; | ||||
| if (checkCouponIsFree(coupon)) { | if (checkCouponIsFree(coupon)) { | ||||
| // 免费券 | // 免费券 | ||||
| order = saveFreeOrderForCoupon(user, coupon, orderSaveDto.getCouponChannelId(), orderSaveDto.getFormId()); | |||||
| order = saveFreeOrderForCoupon(user, coupon, orderSaveDto.getCouponChannelId(), orderSaveDto.getFormId(), null); | |||||
| if(order != null) { | if(order != null) { | ||||
| // 6. 下订单完成,发送内部消息 | // 6. 下订单完成,发送内部消息 | ||||
| // 下订单完成,发送内部消息 | // 下订单完成,发送内部消息 | ||||
| @@ -1394,7 +1404,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| @Override | @Override | ||||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | ||||
| public WxOrder saveFreeOrderForCoupon(WxCUser user, WxCoupon coupon, Long couponChannelId, String formId) { | |||||
| public WxOrder saveFreeOrderForCoupon(WxCUser user, WxCoupon coupon, Long couponChannelId, String formId, Long couponPasswordId) { | |||||
| // 1. check user info and coupon info | // 1. check user info and coupon info | ||||
| userCouponMerchantCheck(user, coupon); | userCouponMerchantCheck(user, coupon); | ||||
| if (coupon.checkIsCreditCoupon()) { | if (coupon.checkIsCreditCoupon()) { | ||||
| @@ -1434,7 +1444,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| // 5. 创建couponOrder | // 5. 创建couponOrder | ||||
| try { | try { | ||||
| createCouponOrder(record, user, coupon); | |||||
| createCouponOrder(record, user, coupon, couponPasswordId); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error("couponOrder失败:" + e.getMessage()); | logger.error("couponOrder失败:" + e.getMessage()); | ||||
| throw new MallinkException(ErrorCode.COUPON_ORDER_SAVE_ERR); | throw new MallinkException(ErrorCode.COUPON_ORDER_SAVE_ERR); | ||||
| @@ -56,7 +56,7 @@ public class SendSmsServiceImpl implements MsgSendService { | |||||
| throw new MallinkException(ErrorCode.MSG_CONFIG_NOT_FOUND); | throw new MallinkException(ErrorCode.MSG_CONFIG_NOT_FOUND); | ||||
| } | } | ||||
| wxMsgConfig = wxMsgConfigs.get(0); | wxMsgConfig = wxMsgConfigs.get(0); | ||||
| if(wxMsgConfig.getRemains() <=0l){ | |||||
| if (wxMsgConfig.getRemains() <= 0L) { | |||||
| throw new MallinkException(ErrorCode.MSG_CONFIG_ACCOUNT); | throw new MallinkException(ErrorCode.MSG_CONFIG_ACCOUNT); | ||||
| } | } | ||||
| @@ -96,7 +96,7 @@ public class SendSmsServiceImpl implements MsgSendService { | |||||
| if (ret.equals("1")) { | if (ret.equals("1")) { | ||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| wxMsgValidationcode.setId(idWorker.nextId()); | wxMsgValidationcode.setId(idWorker.nextId()); | ||||
| long currentTime = System.currentTimeMillis() ; | |||||
| long currentTime = System.currentTimeMillis(); | |||||
| Date createtime=new Date(currentTime); | Date createtime=new Date(currentTime); | ||||
| wxMsgValidationcode.setCreatetime(createtime); | wxMsgValidationcode.setCreatetime(createtime); | ||||
| Integer minutes = wxMsgValidationcodeModel.getMinutes(); | Integer minutes = wxMsgValidationcodeModel.getMinutes(); | ||||
| @@ -106,9 +106,10 @@ public class SendSmsServiceImpl implements MsgSendService { | |||||
| wxMsgValidationcode.setExpiretime(expiredate); | wxMsgValidationcode.setExpiretime(expiredate); | ||||
| } | } | ||||
| wxMsgValidationcodeMapper.insertSelective(wxMsgValidationcode); | wxMsgValidationcodeMapper.insertSelective(wxMsgValidationcode); | ||||
| wxMsgValidationcodeService.addMsgCallback(wxMsgValidationcode,batchNo); | |||||
| String id = record.getDynamicContentMap().get("id"); | |||||
| wxMsgValidationcodeService.addMsgCallback(wxMsgValidationcode, batchNo, id); | |||||
| //扣减剩余条数 | //扣减剩余条数 | ||||
| wxMsgConfig.setRemains(1l); | |||||
| wxMsgConfig.setRemains(1L); | |||||
| wxMsgConfigMapper.updateRemains(wxMsgConfig); | wxMsgConfigMapper.updateRemains(wxMsgConfig); | ||||
| }else{ | }else{ | ||||
| throw new MallinkException(1001,"运营商返回失败:"+result); | throw new MallinkException(1001,"运营商返回失败:"+result); | ||||
| @@ -1099,8 +1099,6 @@ public class DateUtils { | |||||
| * @return <0:已过n天;=0:当天 ;>0 n天前 | * @return <0:已过n天;=0:当天 ;>0 n天前 | ||||
| */ | */ | ||||
| public static int birthdaysBetween(Date date) { | public static int birthdaysBetween(Date date) { | ||||
| Date today = new Date() ; | |||||
| date.setYear(today.getYear()); | |||||
| Calendar todayCal = Calendar.getInstance(); | Calendar todayCal = Calendar.getInstance(); | ||||
| Calendar birthdayCal = Calendar.getInstance(); | Calendar birthdayCal = Calendar.getInstance(); | ||||
| birthdayCal.setTime(date); | birthdayCal.setTime(date); | ||||
| @@ -1,4 +1,4 @@ | |||||
| package com.iformall.utils; | |||||
| package com.iformall.utils.car; | |||||
| import com.alibaba.fastjson.JSON; | import com.alibaba.fastjson.JSON; | ||||
| import com.alibaba.fastjson.JSONArray; | import com.alibaba.fastjson.JSONArray; | ||||
| @@ -1,7 +1,10 @@ | |||||
| package com.iformall.utils; | |||||
| package com.iformall.utils.car; | |||||
| import com.alibaba.fastjson.JSON; | import com.alibaba.fastjson.JSON; | ||||
| import com.alibaba.fastjson.JSONObject; | import com.alibaba.fastjson.JSONObject; | ||||
| import com.iformall.domain.po.WxCoupon; | |||||
| import com.iformall.domain.po.WxCouponOrder; | |||||
| import com.iformall.utils.MapUtil; | |||||
| import org.apache.http.Consts; | import org.apache.http.Consts; | ||||
| import org.apache.http.HttpEntity; | import org.apache.http.HttpEntity; | ||||
| import org.apache.http.HttpResponse; | import org.apache.http.HttpResponse; | ||||
| @@ -27,18 +30,69 @@ import java.util.Map; | |||||
| * 停简单 停车管理 | * 停简单 停车管理 | ||||
| */ | */ | ||||
| @Component | @Component | ||||
| public class TJDCarUtil { | |||||
| private final static Logger logger = LoggerFactory.getLogger(TJDCarUtil.class); | |||||
| public class TJDUtil { | |||||
| public static final String TJD_URL = "url"; | |||||
| public static final String TJD_ACCOUNT = "partner"; | |||||
| public static final String TJD_ACCOUNT_KEY = "key"; | |||||
| public static final String TJD_VERSION = "version"; | |||||
| public static final String TJD_CHARSET = "charset"; | |||||
| public static final String TJD_UTF_8 = "utf-8"; | |||||
| public static final String TJD_RETURN_CODE = "returnCode"; | |||||
| public static final String TJD_RETURN_SUCC = "T"; | |||||
| public static final String TJD_RETURN_FAIL = "F"; | |||||
| public static final String TJD_IS_SUC = "isSuccess"; | |||||
| public static final String TJD_ERR_MSG = "errorMSG"; | |||||
| public static final String TJD_SUC = "0"; | |||||
| public static final String TJD_ERR_1 = "1"; // 业务级失败(不进行重发) | |||||
| public static final String TJD_ERR_2 = "2"; // 系统级失败(有重发机制) | |||||
| public static final String TJD_PARK_ID = "parkId"; | |||||
| public static final String TJD_PARK_NAME = "parkName"; | |||||
| public static final String TJD_CAR_NUMBER = "carNum"; | |||||
| public static final String TJD_TRADE_ID = "tradeId"; | |||||
| public static final String TJD_IN_DT = "inDt"; | |||||
| public static final String TJD_OUT_DT = "outDt"; | |||||
| public static final String TJD_PARK_AMT = "parkAmount"; | |||||
| public static final String TJD_PAY_AMT = "payAmount"; | |||||
| public static final String TJD_PAY_DT = "payDt"; | |||||
| public static final String TJD_FREE_MINS = "freeMins"; | |||||
| public static final String TJD_ACCOUNT_ID = "accountId"; | |||||
| public static final String TJD_PREPAY_TYPE = "prePayType"; | |||||
| public static final String TJD_PREPAY_TYPE_3 = "3"; // 三方合作方支付 | |||||
| public static final String TJD_PREPAY_TYPE_20 = "20"; // 手机场内支付 | |||||
| public static final String TJD_DETAIL_LIST = "detailList"; | |||||
| public static final String TJD_OUT_TRADE_NO = "outTradeNo"; | |||||
| public static final String TJD_TYPE = "type"; | |||||
| public static final String TJD_TYPE_DISCOUNT = "0"; | |||||
| public static final String TJD_TYPE_COUPON = "1"; | |||||
| public static final String TJD_COUPON_TYPE = "couponType"; | |||||
| public static final String TJD_CHANNEL = "channel"; | |||||
| public static final String TJD_AMOUNT = "amount"; | |||||
| public static final String TJD_MINUTES = "minutes"; | |||||
| public static final String TJD_CREDIT = "integral"; | |||||
| public static final String TJD_MEMO = "memo"; | |||||
| public static final SimpleDateFormat dateInFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |||||
| public static final SimpleDateFormat dateOutFormat = new SimpleDateFormat("yyyyMMddHHmmss"); | |||||
| private final static Logger logger = LoggerFactory.getLogger(TJDUtil.class); | |||||
| private static String baseurl = "http://prep.tingjiandan.com/openapi/gateway"; | private static String baseurl = "http://prep.tingjiandan.com/openapi/gateway"; | ||||
| private static String partner = "7dbc8ec9037d403b822cb60addfdc681"; | |||||
| private static String key = "f356cb1bf5a74fb7a564e86128d2c49f"; | |||||
| private static String partner = "fb21a5b2f7064ff5afb8288d5bb48ca8"; | |||||
| private static String key = "bc2f09be8f5b4227898346cf6fe451c2"; | |||||
| private static String version = "1.0"; | private static String version = "1.0"; | ||||
| // | |||||
| // {"url":"http://prep.tingjiandan.com/openapi/gateway","partnerId":"fb21a5b2f7064ff5afb8288d5bb48ca8","key":"bc2f09be8f5b4227898346cf6fe451c2","parkId":"7715622dff834b34a44448b801c27607", "version":"1.0.0"} | |||||
| // | |||||
| public static void main(String[] args) throws Exception { | public static void main(String[] args) throws Exception { | ||||
| String carNumber = "京HLTT01"; | |||||
| String carNumber = "京XAZMF1"; | |||||
| String result = infoForFreeMins(baseurl, partner, key, version, carNumber); | String result = infoForFreeMins(baseurl, partner, key, version, carNumber); | ||||
| @@ -50,9 +104,9 @@ public class TJDCarUtil { | |||||
| paramMap1.put("deductionAmount", obj.getString("totalAmount")); | paramMap1.put("deductionAmount", obj.getString("totalAmount")); | ||||
| paramMap1.put("outTradeNo", "utf-8"); | paramMap1.put("outTradeNo", "utf-8"); | ||||
| paramMap1.put("accountId", obj.getString("accountId")); | paramMap1.put("accountId", obj.getString("accountId")); | ||||
| paramMap1.put("charset", "utf-8"); | |||||
| paramMap1.put("partner", partner); | |||||
| paramMap1.put("version", version); | |||||
| paramMap1.put(TJD_CHARSET, "utf-8"); | |||||
| paramMap1.put(TJD_ACCOUNT, partner); | |||||
| paramMap1.put(TJD_VERSION, version); | |||||
| deductionNotSettle(baseurl, key, paramMap1); | deductionNotSettle(baseurl, key, paramMap1); | ||||
| */ | */ | ||||
| @@ -84,8 +138,7 @@ public class TJDCarUtil { | |||||
| */ | */ | ||||
| public static String getCurrentDate() { | public static String getCurrentDate() { | ||||
| Date currentDate = new Date(); | Date currentDate = new Date(); | ||||
| SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |||||
| String timestamp = sdf.format(currentDate); | |||||
| String timestamp = dateInFormat.format(currentDate); | |||||
| return timestamp; | return timestamp; | ||||
| } | } | ||||
| @@ -134,7 +187,7 @@ public class TJDCarUtil { | |||||
| String service = "parkhub.car.register"; | String service = "parkhub.car.register"; | ||||
| Map<String, String> paramMap = MapUtil.getOrderMap(); | Map<String, String> paramMap = MapUtil.getOrderMap(); | ||||
| paramMap.put("carNum", carNum); | |||||
| paramMap.put(TJD_CAR_NUMBER, carNum); | |||||
| paramMap.put("carNumColor", carNumColor); | paramMap.put("carNumColor", carNumColor); | ||||
| if (phone != null) { | if (phone != null) { | ||||
| paramMap.put("phone", phone); | paramMap.put("phone", phone); | ||||
| @@ -142,9 +195,9 @@ public class TJDCarUtil { | |||||
| if (outCarId != null) { | if (outCarId != null) { | ||||
| paramMap.put("outCardId", outCarId); | paramMap.put("outCardId", outCarId); | ||||
| } | } | ||||
| paramMap.put("charset", "utf-8"); | |||||
| paramMap.put("partner", partner); | |||||
| paramMap.put("version", version); | |||||
| paramMap.put(TJD_CHARSET, TJD_UTF_8); | |||||
| paramMap.put(TJD_ACCOUNT, partner); | |||||
| paramMap.put(TJD_VERSION, version); | |||||
| String result = Proc(url, key, service, paramMap); | String result = Proc(url, key, service, paramMap); | ||||
| @@ -185,9 +238,9 @@ public class TJDCarUtil { | |||||
| Map<String, String> paramMap = MapUtil.getOrderMap(); | Map<String, String> paramMap = MapUtil.getOrderMap(); | ||||
| paramMap.put("carId", carId); | paramMap.put("carId", carId); | ||||
| paramMap.put("charset", "utf-8"); | |||||
| paramMap.put("partner", partner); | |||||
| paramMap.put("version", version); | |||||
| paramMap.put(TJD_CHARSET, TJD_UTF_8); | |||||
| paramMap.put(TJD_ACCOUNT, partner); | |||||
| paramMap.put(TJD_VERSION, version); | |||||
| String result = Proc(url, key, service, paramMap); | String result = Proc(url, key, service, paramMap); | ||||
| @@ -227,43 +280,141 @@ public class TJDCarUtil { | |||||
| String freeMins = "0"; | String freeMins = "0"; | ||||
| Map<String, String> paramMap = MapUtil.getOrderMap(); | Map<String, String> paramMap = MapUtil.getOrderMap(); | ||||
| paramMap.put("carNum", carNum); | |||||
| paramMap.put(TJD_CAR_NUMBER, carNum); | |||||
| //paramMap.put("carNumColor", ""); | //paramMap.put("carNumColor", ""); | ||||
| //paramMap.put("pmParkId", ""); | //paramMap.put("pmParkId", ""); | ||||
| paramMap.put("freeMins", freeMins); | |||||
| paramMap.put(TJD_FREE_MINS, freeMins); | |||||
| //paramMap.put("tradeId", ""); | //paramMap.put("tradeId", ""); | ||||
| paramMap.put("charset", "utf-8"); | |||||
| paramMap.put("partner", partner); | |||||
| paramMap.put("version", version); | |||||
| paramMap.put(TJD_CHARSET, TJD_UTF_8); | |||||
| paramMap.put(TJD_ACCOUNT, partner); | |||||
| paramMap.put(TJD_VERSION, version); | |||||
| String result = Proc(url, key, service, paramMap); | String result = Proc(url, key, service, paramMap); | ||||
| /* | /* | ||||
| "{ | |||||
| \"wLon\":\"116.310335\", | |||||
| { | |||||
| "wLon":"116.310335", | |||||
| "returnCode":"T", | |||||
| "lon":"116.316813", | |||||
| "accountId":"818a6ac865e841119ec9aab21c5e5a24", | |||||
| "freeThroughTime":"10", | |||||
| "customerServicePhone":"400-001-0606", | |||||
| "tradeId":"2ae003431584495081014428c90173ab", | |||||
| "returnMsg":"OK", | |||||
| "outDt":"20190920110443", | |||||
| "isSuccess":"0", | |||||
| "miniProgram":"{\"path\": \"pages/pre_pay/index/main\",\"extraData\": {\"prePayType\": \"16\",\"channel\": \"30166\",\"isShowDetail\": \"true\",\"partnerId\": \"956ca31ac8464cf7b6a876e8887912f3\",\"orderId\": \"2ae003431584495081014428c90173ab\"}}","pmParkId":"7715622dff834b34a44448b801c27607","unPayAmount":"88.12","timestamp":"1568948681580","errorMSG":"","parkTime":"81629","wLat":"39.93609","totalAmount":"88.12","paidAmount":"0.00","freeMinsAmount":"0.00","payUrl":"https://prep.tingjiandan.com/tcweixin/letter/prePay/pagePayInPark?prePayType=16&channel=30166&isShowDetail=true&partnerId=&orderId=2ae003431584495081014428c90173ab&returnUrl=", | |||||
| "lat":"39.942078", | |||||
| "inDt":"20190919122414"} | |||||
| */ | |||||
| return result; | |||||
| } | |||||
| //// TODO | |||||
| /** | |||||
| * deductionNotSettle 停车费批量抵扣接口 | |||||
| * @param url | |||||
| * @param partner | |||||
| * @param key // 密钥 | |||||
| * @param version | |||||
| * type 可选值:0=抵扣、1=优惠券 | |||||
| * couponType type=1时必填,可选值:0=金额、1=时长、2=全免、3=时间区间 | |||||
| * channel 可选值: type=0时:5013=微信、5014=支付宝、5015=抵扣其他 | |||||
| * type=1时:2202=会员等级、2203=会员积分、2204=会员卡券、2205=会员补贴、2206=会员其他 | |||||
| * amount: type=0时、couponType=0必填,单位(元),保留小数点后两位,金额类型使用 | |||||
| * minutes: couponType=1时必填,单位(分钟),时长类型使用 | |||||
| * integral: 大于等于0的整数值,积分类型使用,如果使用了积分兑换,可填写积分值 | |||||
| * expireDt: type=1时选填,格式:yyyyMMddHHmmss,如果不填,则永不过期,若填写,则出场时间在此 时间之后,认为此记录已经过期,不再使用 | |||||
| * membershipGrade: 调用方系统会员等级标识,如:LV1、VIP2、金卡等,长度不超过64位 | |||||
| * identityType: identityId非空时,此值必填,可选值:01=手机号、02=会员卡号、03=车牌号、04=身份证号 | |||||
| * identityId: identityType非空时,此值必填,对应身份标识类型的唯一值,长度不超过100位 | |||||
| * { | |||||
| "service": "parkhub.order.deductionForDetail", | |||||
| "partner": "120a565de377427184de35ca0f320764", | |||||
| "sign": "3347b109a1e44f3fd5baa78b74a84948", | |||||
| "signType": "md5", | |||||
| "charset": "utf-8", | |||||
| "version": "1.0", | |||||
| "timestamp": "2016-05-26 11:30:10", | |||||
| "tradeId": "c39d3aac49d04e12a187681e6189f841", | |||||
| "accountId": "a9b2963c98344bb292e0fa3f7dd70946", | |||||
| "prePayType": "3", | |||||
| "giveFreeTimeOut": "false", | |||||
| "detailList":"[{ | |||||
| \"outTradeNo\":\"PLDKY01\", | |||||
| \"identityType\":\"01\", | |||||
| \"identityId\":\"17710111111\", | |||||
| \"membershipGrade\":\"LV1\", | |||||
| \"amount\":\"12.50\", | |||||
| \"type\":\"0\", | |||||
| \"channel\":\"5013\", | |||||
| \"memo\":\"批量抵扣-金额-微信\" | |||||
| },{ | |||||
| \"outTradeNo\":\"PLDKY02\", | |||||
| \"identityType\":\"01\", | |||||
| \"identityId\":\"17710111111\", | |||||
| \"membershipGrade\":\"LV1\", | |||||
| \"couponType\":\"1\", | |||||
| \"minutes\":\"60\", | |||||
| \"type\":\"1\", | |||||
| \"channel\":\"2204\", | |||||
| \"memo\":\"批量抵扣-时长-会员卡券\" | |||||
| },{ | |||||
| \"outTradeNo\":\"PLDKY03\", | |||||
| \"identityType\":\"01\", | |||||
| \"identityId\":\"17710111111\", | |||||
| \"membershipGrade\":\"LV1\", | |||||
| \"couponType\":\"3\", | |||||
| \"startDt\":\"20180901110000\", | |||||
| \"endDt\":\"20180901170000\", | |||||
| \"integral\":\"500\", | |||||
| \"type\":\"1\", | |||||
| \"channel\":\"2205\", \"memo\":\"批量抵扣-区间-积分-会员补贴\" | |||||
| }]" | |||||
| } | |||||
| * @throws Exception | |||||
| */ | |||||
| public static String deductionForDetail( | |||||
| String url, String partner, String key, String version, | |||||
| String tradeId, String accountId, | |||||
| WxCouponOrder couponOrder, WxCoupon coupon) { | |||||
| // 为指定订单抵扣停车费,如果此时车辆已经出场,返回isSuccess错误码为3,停简单系统不再接收此笔抵扣信息,对方系统 需要给用户发起退款。 | |||||
| String service = "parkhub.order.deductionForDetail"; | |||||
| Map<String, String> paramMap = MapUtil.getOrderMap(); | |||||
| paramMap.put(TJD_TRADE_ID, tradeId); | |||||
| paramMap.put(TJD_ACCOUNT_ID, accountId); | |||||
| paramMap.put(TJD_PREPAY_TYPE, TJD_PREPAY_TYPE_3); | |||||
| Map<String, String> detailMap = MapUtil.getOrderMap(); | |||||
| detailMap.put(TJD_OUT_TRADE_NO, String.valueOf(couponOrder.getId())); | |||||
| detailMap.put(TJD_TYPE, TJD_TYPE_COUPON); | |||||
| detailMap.put(TJD_CHANNEL, "2204"); | |||||
| String memo = "会员优惠券"; | |||||
| if (coupon.getUnit().equals(0)) { | |||||
| detailMap.put(TJD_COUPON_TYPE, "0"); | |||||
| detailMap.put(TJD_AMOUNT, coupon.getPriceStr()); | |||||
| memo += "-金额"; | |||||
| } else { | |||||
| detailMap.put(TJD_COUPON_TYPE, "1"); | |||||
| detailMap.put(TJD_MINUTES, String.valueOf(coupon.getPrice()*60)); | |||||
| memo += "-时长"; | |||||
| } | |||||
| detailMap.put(TJD_MEMO, memo); | |||||
| paramMap.put(TJD_DETAIL_LIST, JSON.toJSONString(detailMap)); | |||||
| paramMap.put(TJD_CHARSET, TJD_UTF_8); | |||||
| paramMap.put(TJD_ACCOUNT, partner); | |||||
| paramMap.put(TJD_VERSION, version); | |||||
| String result = Proc(url, key, service, paramMap); | |||||
| /* | |||||
| "{\"timestamp\":\"1528534986636\", | |||||
| \"returnCode\":\"T\", | \"returnCode\":\"T\", | ||||
| \"lon\":\"116.316819\", | |||||
| \"accountId\":\"5b3c15e15235486eba9abae41ae3f820\", | |||||
| \"freeThroughTime\":\"30\", | |||||
| \"customerServicePhone\":\"400-001-0606\", | |||||
| \"tradeId\":\"3a3475c501f8464cbb3ff1b6670690d6\", | |||||
| \"returnMsg\":\"OK\", | |||||
| \"outDt\":\"20180609164753\", | |||||
| \"isSuccess\":\"0\", | |||||
| \"pmParkId\":\"7715622dff834b34a44448b801c27607\", | |||||
| \"unPayAmount\":\"12.00\", | |||||
| \"timestamp\":\"1528534070691\", | |||||
| \"prePayId\":\"7a1d52aa77ca487db4e61130394285bd\", | |||||
| \"errorMSG\":\"\", | \"errorMSG\":\"\", | ||||
| \"parkTime\":\"107273\", | |||||
| \"wLat\":\"39.93609\", | |||||
| \"totalAmount\":\"12.00\", | |||||
| \"paidAmount\":\"0.00\", | |||||
| \"freeMinsAmount\":\"0\", | |||||
| \"payUrl\":\"https://prep.tingjiandan.com/tcweixin/letter/prePay/payInPark.html?prePayType=16&channel=30040&isShowDetail=true&orderId=3a3475c501f8464cbb3ff1b6670690d6\", | |||||
| \"lat\":\"39.942078\", | |||||
| \"inDt\":\"20180608110000\" | |||||
| }\n"; | |||||
| */ | |||||
| \"returnMsg\":\"OK\", | |||||
| \"isSuccess\":\"0\"}[\\r][\\n]" | |||||
| */ | |||||
| return result; | return result; | ||||
| } | } | ||||
| @@ -299,9 +450,9 @@ public class TJDCarUtil { | |||||
| paramMap.put("deductionAmount", deductionAmount); | paramMap.put("deductionAmount", deductionAmount); | ||||
| paramMap.put("outTradeNo", outTradeNo); | paramMap.put("outTradeNo", outTradeNo); | ||||
| paramMap.put("accountId", accountId); | paramMap.put("accountId", accountId); | ||||
| paramMap.put("charset", "utf-8"); | |||||
| paramMap.put("partner", partner); | |||||
| paramMap.put("version", version); | |||||
| paramMap.put(TJD_CHARSET, TJD_UTF_8); | |||||
| paramMap.put(TJD_ACCOUNT, partner); | |||||
| paramMap.put(TJD_VERSION, version); | |||||
| String result = Proc(url, key, service, paramMap); | String result = Proc(url, key, service, paramMap); | ||||
| /* | /* | ||||
| @@ -350,9 +501,9 @@ public class TJDCarUtil { | |||||
| paramMap.put("prePayType", prePayType); | paramMap.put("prePayType", prePayType); | ||||
| paramMap.put("minutes", minutes); | paramMap.put("minutes", minutes); | ||||
| paramMap.put("memo", memo); | paramMap.put("memo", memo); | ||||
| paramMap.put("charset", "utf-8"); | |||||
| paramMap.put("partner", partner); | |||||
| paramMap.put("version", version); | |||||
| paramMap.put(TJD_CHARSET, TJD_UTF_8); | |||||
| paramMap.put(TJD_ACCOUNT, partner); | |||||
| paramMap.put(TJD_VERSION, version); | |||||
| String result = Proc(url, key, service, paramMap); | String result = Proc(url, key, service, paramMap); | ||||
| /*{ | /*{ | ||||
| @@ -406,9 +557,9 @@ public class TJDCarUtil { | |||||
| paramMap.put("EndDt", EndDt); | paramMap.put("EndDt", EndDt); | ||||
| paramMap.put("expireDt", expireDt); | paramMap.put("expireDt", expireDt); | ||||
| paramMap.put("memo", memo); | paramMap.put("memo", memo); | ||||
| paramMap.put("charset", "utf-8"); | |||||
| paramMap.put("partner", partner); | |||||
| paramMap.put("version", version); | |||||
| paramMap.put(TJD_CHARSET, TJD_UTF_8); | |||||
| paramMap.put(TJD_ACCOUNT, partner); | |||||
| paramMap.put(TJD_VERSION, version); | |||||
| String result = Proc(url, key, service, paramMap); | String result = Proc(url, key, service, paramMap); | ||||
| /*{ | /*{ | ||||
| @@ -449,9 +600,9 @@ public class TJDCarUtil { | |||||
| Map<String, String> paramMap = MapUtil.getOrderMap(); | Map<String, String> paramMap = MapUtil.getOrderMap(); | ||||
| paramMap.put("tradeId", tradeId); | paramMap.put("tradeId", tradeId); | ||||
| paramMap.put("ticketid", ticketid); | paramMap.put("ticketid", ticketid); | ||||
| paramMap.put("charset", "utf-8"); | |||||
| paramMap.put("partner", partner); | |||||
| paramMap.put("version", version); | |||||
| paramMap.put(TJD_CHARSET, TJD_UTF_8); | |||||
| paramMap.put(TJD_ACCOUNT, partner); | |||||
| paramMap.put(TJD_VERSION, version); | |||||
| String result = Proc(url, key, service, paramMap); | String result = Proc(url, key, service, paramMap); | ||||
| /*{ | /*{ | ||||
| @@ -526,5 +526,8 @@ | |||||
| UPDATE wx_c_user_basic_info set act_record = act_record +1 where id = #{id} | UPDATE wx_c_user_basic_info set act_record = act_record +1 where id = #{id} | ||||
| </update> | </update> | ||||
| <select id="selectNotCUserList" resultMap="BaseResultMap"> | |||||
| select id,credit from wx_c_user_basic_info cub where not exists (select * from wx_c_user c where c.id=cub.id) and cub.credit is null | |||||
| </select> | |||||
| </mapper> | </mapper> | ||||
| @@ -43,6 +43,7 @@ | |||||
| <result column="cancle_apply_status" property="cancleApplyStatus"/> | <result column="cancle_apply_status" property="cancleApplyStatus"/> | ||||
| <result column="conditions" jdbcType="VARCHAR" property="conditions"/> | <result column="conditions" jdbcType="VARCHAR" property="conditions"/> | ||||
| <result column="approval_type" property="approvalType"/> | <result column="approval_type" property="approvalType"/> | ||||
| <result column="password_support" property="passwordSupport"/> | |||||
| </resultMap> | </resultMap> | ||||
| <resultMap id="statisMap" type="com.iformall.domain.vo.WxCouponStatisVo"> | <resultMap id="statisMap" type="com.iformall.domain.vo.WxCouponStatisVo"> | ||||
| <id column="id" jdbcType="BIGINT" property="id"/> | <id column="id" jdbcType="BIGINT" property="id"/> | ||||
| @@ -0,0 +1,161 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||||
| <mapper namespace="com.iformall.mapper.WxCouponPasswordMapper"> | |||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCouponPassword"> | |||||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||||
| <result column="coupon_id" jdbcType="BIGINT" property="couponId" /> | |||||
| <result column="coupon_short" jdbcType="VARCHAR" property="couponShort" /> | |||||
| <result column="password" jdbcType="VARCHAR" property="password" /> | |||||
| <result column="status" jdbcType="INTEGER" property="status" /> | |||||
| <result column="sended_phone" jdbcType="VARCHAR" property="sendedPhone" /> | |||||
| <result column="card_id" jdbcType="BIGINT" property="cardId" /> | |||||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | |||||
| <result column="expire_date" jdbcType="TIMESTAMP" property="expireDate" /> | |||||
| <result column="present_id" jdbcType="TIMESTAMP" property="presentId"/> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| `id`,`tenant_id`,`coupon_id`,`coupon_short`,`password`,`status`,`sended_phone`,`card_id`,`create_date`,`update_date`,`expire_date`,`present_id` | |||||
| </sql> | |||||
| <sql id="dynamicWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> | |||||
| and `id` = #{id} | |||||
| </if> | |||||
| <if test=" null != tenantId "> | |||||
| and `tenant_id` = #{tenantId} | |||||
| </if> | |||||
| <if test=" null != couponId "> | |||||
| and `coupon_id` = #{couponId} | |||||
| </if> | |||||
| <if test=" null != couponShort "> | |||||
| and `coupon_short` = #{couponShort} | |||||
| </if> | |||||
| <if test=" null != password "> | |||||
| and `password` = #{password} | |||||
| </if> | |||||
| <if test=" null != status "> | |||||
| and `status` = #{status} | |||||
| </if> | |||||
| <if test=" null != sendedPhone "> | |||||
| and `sended_phone` = #{sendedPhone} | |||||
| </if> | |||||
| <if test=" null != cardId "> | |||||
| and `card_id` = #{cardId} | |||||
| </if> | |||||
| <if test=" null != createDate "> | |||||
| and `create_date` = #{createDate} | |||||
| </if> | |||||
| <if test=" null != updateDate "> | |||||
| and `update_date` = #{updateDate} | |||||
| </if> | |||||
| <if test=" null != expireDate "> | |||||
| and `expire_date` > #{expireDate} | |||||
| </if> | |||||
| <if test=" null != presentId "> | |||||
| and `present_id` = #{presentId} | |||||
| </if> | |||||
| <if test=" null != ids "> | |||||
| and id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != statusStr and ''!=statusStr"> | |||||
| and status in (${statusStr}) | |||||
| </if> | |||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||||
| </sql> | |||||
| <select id="findList" parameterType="com.iformall.domain.po.WxCouponPassword" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> | |||||
| from wx_coupon_password | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| <select id="findAvaPasswordListByCouponId" parameterType="com.iformall.domain.po.WxCouponPassword" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> | |||||
| from wx_coupon_password | |||||
| <where> | |||||
| <if test=" null != tenantId "> | |||||
| and `tenant_id` = #{tenantId} | |||||
| </if> | |||||
| <if test=" null != couponId "> | |||||
| and `coupon_id` = #{couponId} | |||||
| </if> | |||||
| <if test=" null != expireDate "> | |||||
| and `expire_date` > #{expireDate} | |||||
| </if> | |||||
| </where> | |||||
| </select> | |||||
| <insert id="insertCouponPasswds" parameterType="java.util.List"> | |||||
| INSERT INTO wx_coupon_password (`id`,`coupon_id`,`coupon_short`,`password`,`status`,`create_date`,`update_date`) | |||||
| VALUES | |||||
| <foreach collection="list" item="item" index="index" separator=","> | |||||
| ( | |||||
| #{item.id},#{item.couponId},#{item.couponShort},#{item.password},#{item.status}, | |||||
| #{item.createDate},#{item.updateDate} | |||||
| ) | |||||
| </foreach> | |||||
| </insert> | |||||
| <update id="disableByCouponId" parameterType="Long"> | |||||
| update wx_coupon_password | |||||
| set status=4, update_date=now() | |||||
| where status != 3 and coupon_id=#{couponId} | |||||
| </update> | |||||
| <update id="downloadByCouponId" parameterType="Long"> | |||||
| update wx_coupon_password | |||||
| set status=1, update_date=now(), expire_date=date_add(now(),interval 30 DAY) | |||||
| where status=0 and coupon_id=#{couponId} | |||||
| </update> | |||||
| <select id="findCouponGroupList" parameterType="com.iformall.domain.po.WxCouponPassword" resultMap="BaseResultMap"> | |||||
| select `coupon_id`,`coupon_short` | |||||
| from wx_coupon_password | |||||
| where `tenant_id` = #{tenantId} | |||||
| group by `coupon_id`,`coupon_short` | |||||
| </select> | |||||
| <resultMap id="CouponCountInfoMap" type="com.iformall.domain.vo.WxCouponPasswordCountInfoVO"> | |||||
| <result column="coupon_count" jdbcType="BIGINT" property="couponCount"/> | |||||
| <result column="title" jdbcType="VARCHAR" property="couponName"/> | |||||
| <result column="coupon_id" jdbcType="BIGINT" property="couponId"/> | |||||
| <result column="price" jdbcType="VARCHAR" property="price"/> | |||||
| </resultMap> | |||||
| <select id="findCouponCountInfo" parameterType="com.iformall.domain.po.WxCouponPassword" | |||||
| resultMap="CouponCountInfoMap"> | |||||
| select cp.coupon_id,c.title,c.price,cp.coupon_count from | |||||
| (select count(*) as coupon_count,coupon_id from wx_coupon_password | |||||
| where tenant_id=#{tenantId} and status=0 group by coupon_id) cp | |||||
| inner join wx_coupon c on cp.coupon_id = c.id | |||||
| where c.tenant_id=#{tenantId} and c.status=0 | |||||
| <if test=" null != couponId "> | |||||
| and cp.`coupon_id` = #{couponId} | |||||
| </if> | |||||
| group by cp.coupon_id | |||||
| order by c.create_date desc | |||||
| </select> | |||||
| <update id="updateStatus" parameterType="java.util.List"> | |||||
| <foreach collection="list" item="item" index="index" open="" close="" separator=";"> | |||||
| update wx_coupon_password set | |||||
| status=1,sended_phone=#{item.sendedPhone},update_date=now(),expire_date=date_add(now(),interval 30 DAY), | |||||
| present_id=#{item.presentId} | |||||
| where id = #{item.id} | |||||
| </foreach> | |||||
| </update> | |||||
| </mapper> | |||||
| @@ -0,0 +1,58 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||||
| <mapper namespace="com.iformall.mapper.WxCouponPresentMapper"> | |||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCouponPresent"> | |||||
| <id column="id" jdbcType="BIGINT" property="id"/> | |||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | |||||
| <result column="user_id" jdbcType="BIGINT" property="userId"/> | |||||
| <result column="coupon_id" jdbcType="BIGINT" property="couponId"/> | |||||
| <result column="coupon_name" jdbcType="VARCHAR" property="couponName"/> | |||||
| <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/> | |||||
| <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/> | |||||
| <result column="send_amount" jdbcType="INTEGER" property="sendAmount"/> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| `id`,`tenant_id`,`coupon_id`,`coupon_name`,`user_id`,`create_time`,`update_time`,`send_amount` | |||||
| </sql> | |||||
| <sql id="dynamicWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> | |||||
| and `id` = #{id} | |||||
| </if> | |||||
| <if test=" null != tenantId "> | |||||
| and `tenant_id` = #{tenantId} | |||||
| </if> | |||||
| <if test=" null != couponId "> | |||||
| and `coupon_id` = #{couponId} | |||||
| </if> | |||||
| <if test=" null != couponName "> | |||||
| and `coupon_name` like concat('%', #{couponName},'%') | |||||
| </if> | |||||
| <if test=" null != phones "> | |||||
| and `phones` like concat('%', #{phones},'%') | |||||
| </if> | |||||
| <if test=" null != sendTimeStart and null!=sendTimeEnd "> | |||||
| and `create_time` between #{sendTimeStart} and #{sendTimeEnd} | |||||
| </if> | |||||
| <if test=" null != updateTime "> | |||||
| and `update_time` = #{updateTime} | |||||
| </if> | |||||
| <if test=" null != ids "> | |||||
| and id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | |||||
| </sql> | |||||
| <select id="findList" parameterType="com.iformall.domain.po.WxCouponPresent" resultMap="BaseResultMap"> | |||||
| select | |||||
| <include refid="allColumns"/> | |||||
| from wx_coupon_present | |||||
| <include refid="dynamicWhereConditions"/> | |||||
| </select> | |||||
| </mapper> | |||||
| @@ -210,10 +210,7 @@ | |||||
| <select id="getTotalCreditAmount" parameterType="com.iformall.domain.po.WxCreditHistory" | <select id="getTotalCreditAmount" parameterType="com.iformall.domain.po.WxCreditHistory" | ||||
| resultType="java.lang.Long"> | resultType="java.lang.Long"> | ||||
| select ifnull(sum(credit.amount),0) amount from ( | select ifnull(sum(credit.amount),0) amount from ( | ||||
| select credit.credit_amount as amount,credit.c_user_id from wx_credit_history credit | |||||
| INNER join (select max(create_date) create_date,credit.c_user_id | |||||
| from wx_credit_history credit group by credit.c_user_id) credit_max_id | |||||
| on credit.create_date=credit_max_id.create_date | |||||
| select basic.credit as amount,credit.c_user_id from wx_credit_history credit | |||||
| INNER JOIN wx_c_user_basic_info basic ON basic.id = credit.c_user_id | INNER JOIN wx_c_user_basic_info basic ON basic.id = credit.c_user_id | ||||
| LEFT JOIN wx_merchant merchant ON credit.merchant_id = merchant.id | LEFT JOIN wx_merchant merchant ON credit.merchant_id = merchant.id | ||||
| <include refid="customWhereConditions"/> | <include refid="customWhereConditions"/> | ||||
| @@ -249,8 +246,4 @@ | |||||
| ) credit | ) credit | ||||
| </select> | </select> | ||||
| <select id="findListAfter" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> from wx_credit_history where create_date > #{dateTime} and credit_type = #{creditType} | |||||
| </select> | |||||
| </mapper> | </mapper> | ||||
| @@ -15,11 +15,12 @@ | |||||
| <result column="updatetime" jdbcType="TIMESTAMP" property="updatetime" /> | <result column="updatetime" jdbcType="TIMESTAMP" property="updatetime" /> | ||||
| <result column="callback_id" jdbcType="BIGINT" property="callbackId" /> | <result column="callback_id" jdbcType="BIGINT" property="callbackId" /> | ||||
| <result column="msg_id" jdbcType="BIGINT" property="msgId" /> | <result column="msg_id" jdbcType="BIGINT" property="msgId" /> | ||||
| <result column="business_id" jdbcType="BIGINT" property="businessId"/> | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`,`tenant_id`,`batch_no`,`phone`,`begintime`,`endtime`,`status`,`status_msg`,`sign`,`createtime`,`updatetime`,`msg_id`,`callback_id` | |||||
| `id`,`tenant_id`,`batch_no`,`phone`,`begintime`,`endtime`,`status`,`status_msg`,`sign`,`createtime`,`updatetime`,`msg_id`,`callback_id`,`business_id` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| @@ -8,16 +8,11 @@ import com.iformall.domain.po.*; | |||||
| import com.iformall.enums.EnumMsgModel; | import com.iformall.enums.EnumMsgModel; | ||||
| import com.iformall.enums.EnumScoreType; | import com.iformall.enums.EnumScoreType; | ||||
| import com.iformall.enums.EnumUserType; | import com.iformall.enums.EnumUserType; | ||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.mapper.*; | import com.iformall.mapper.*; | ||||
| import com.iformall.service.WxCreditHistoryService; | import com.iformall.service.WxCreditHistoryService; | ||||
| import com.iformall.utils.DateUtils; | |||||
| import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.transaction.annotation.Transactional; | import org.springframework.transaction.annotation.Transactional; | ||||
| import org.springframework.web.bind.annotation.GetMapping; | |||||
| import org.springframework.web.bind.annotation.RequestMapping; | |||||
| import org.springframework.web.bind.annotation.RestController; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import javax.annotation.Resource; | import javax.annotation.Resource; | ||||
| import java.math.BigDecimal; | import java.math.BigDecimal; | ||||
| @@ -62,6 +57,22 @@ public class DataInitController extends BaseController { | |||||
| private WxMerchantMapper wxMerchantMapper; | private WxMerchantMapper wxMerchantMapper; | ||||
| @PostMapping("/createMsgModel") | |||||
| public ResultData createMsgModel(@RequestParam String content, @RequestParam Integer code) { | |||||
| try { | |||||
| MallUserInfo userInfo = getUser(); | |||||
| if (userInfo.isFmSuperAdmin()) { | |||||
| addMsgModel(content, code); | |||||
| return new ResultData(); | |||||
| } | |||||
| } catch (Exception e) { | |||||
| log.error("DataInitController::createMsgModel error ", e); | |||||
| return new ResultData(ErrorCode.MSG_METHOD_REQUEST_ERROR, e.getMessage()); | |||||
| } | |||||
| return new ResultData(); | |||||
| } | |||||
| @GetMapping("/init") | @GetMapping("/init") | ||||
| public ResultData init() { | public ResultData init() { | ||||
| try { | try { | ||||
| @@ -79,27 +90,6 @@ public class DataInitController extends BaseController { | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| /** | |||||
| * 积分数据修复 | |||||
| * | |||||
| * @return | |||||
| */ | |||||
| @GetMapping("/fixCredit") | |||||
| public ResultData fixCredit() { | |||||
| try { | |||||
| MallUserInfo userInfo = getUser(); | |||||
| if(userInfo.isFmSuperAdmin()) { | |||||
| doFixCredit(); | |||||
| return new ResultData(); | |||||
| } | |||||
| } catch (Exception e) { | |||||
| log.error("DataInitController::fixCredit error ", e); | |||||
| return new ResultData(ErrorCode.MSG_METHOD_REQUEST_ERROR, e.getMessage()); | |||||
| } | |||||
| return new ResultData(); | |||||
| } | |||||
| /** | /** | ||||
| * 核销积分数据修复 | * 核销积分数据修复 | ||||
| * | * | ||||
| @@ -121,64 +111,6 @@ public class DataInitController extends BaseController { | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @Transactional(rollbackFor = Exception.class) | |||||
| public void doFixCredit() { | |||||
| // 1 获取积分记录 | |||||
| List<WxCreditHistory> creditList = creditHistoryMapper.findListAfter(10, "2019-09-16 22:00:00"); | |||||
| // 2 重新计算积分,比较是否需要修复 | |||||
| creditList.forEach(wxCreditHistory -> { | |||||
| WxCUser cUser = cUserMapper.selectByPrimaryKey(wxCreditHistory.getCUserId()); | |||||
| WxCUserBasicInfo userBasicInfo = cUserBasicInfoMapper.selectByPrimaryKey(wxCreditHistory.getCUserId()); | |||||
| //排查不存在的用户 | |||||
| if (Objects.isNull(cUser) && Objects.isNull(userBasicInfo)) { | |||||
| log.debug("用户不存在 id: {}", wxCreditHistory.getId()); | |||||
| return; | |||||
| } | |||||
| WxMerchant wxMerchant = new WxMerchant(); | |||||
| wxMerchant.setStatus(1); | |||||
| wxMerchant.setId(wxCreditHistory.getMerchantId()); | |||||
| List<WxMerchant> wxMerchantList = wxMerchantMapper.findList(wxMerchant); | |||||
| if (wxMerchantList == null || wxMerchantList.size() == 0) { | |||||
| log.debug(ErrorCode.MERCHANT_INFO_NOT_FOUND.getMessage()); | |||||
| return; | |||||
| } | |||||
| //根据商户id和花费金额计算需要新增的积分 | |||||
| Map<String, Integer> result = creditHistoryService.findByMerchantIdAndSpend(wxCreditHistory.getMerchantId(), String.valueOf(new BigDecimal(wxCreditHistory.getSpend()/100)), wxCreditHistory.getCUserId(),wxCreditHistory.getTenantId()); | |||||
| //Map<String, Integer> result = creditHistoryService.findByMerchantIdAndSpend(wxCreditHistory.getMerchantId(), String.valueOf(wxCreditHistory.getSpend()), wxCreditHistory.getCUserId(), wxCreditHistory.getTenantId()); | |||||
| Integer creditDB = wxCreditHistory.getCreditNum(); | |||||
| Integer credit = result.get("credit"); | |||||
| if (Objects.equals(credit, creditDB)) { | |||||
| log.debug("本次积分计算:正确, id: {},原积分: {},重新计算积分: {}, 积分时间: {}", wxCreditHistory.getId(), creditDB, credit, DateUtils.format(wxCreditHistory.getCreateDate())); | |||||
| } else { | |||||
| log.debug("本次积分计算:错误, id: {},原积分: {},重新计算积分: {}, 积分时间: {}", wxCreditHistory.getId(), creditDB, credit, DateUtils.format(wxCreditHistory.getCreateDate())); | |||||
| // 3 重新计算积分 | |||||
| //用户新积分 | |||||
| Integer newCredit = wxCreditHistory.getCreditAmount() - creditDB + credit; | |||||
| // 4 更新积分 | |||||
| WxCUser toUpdateCUser = new WxCUser(); | |||||
| toUpdateCUser.setId(wxCreditHistory.getCUserId()); | |||||
| toUpdateCUser.setCredit(newCredit); | |||||
| toUpdateCUser.setUpdateDate(new Date()); | |||||
| cUserMapper.updateByPrimaryKeySelective(toUpdateCUser); | |||||
| WxCUserBasicInfo toUpdateBasicInfo = new WxCUserBasicInfo(); | |||||
| toUpdateBasicInfo.setId(wxCreditHistory.getCUserId()); | |||||
| toUpdateBasicInfo.setCredit(newCredit); | |||||
| toUpdateBasicInfo.setUpdateDate(new Date()); | |||||
| cUserBasicInfoMapper.updateByPrimaryKeySelective(toUpdateBasicInfo); | |||||
| WxCreditHistory toUpdateCreditHistory = new WxCreditHistory(); | |||||
| toUpdateCreditHistory.setId(wxCreditHistory.getId()); | |||||
| toUpdateCreditHistory.setCreditNum(credit); | |||||
| toUpdateCreditHistory.setCreditAmount(newCredit); | |||||
| creditHistoryMapper.updateByPrimaryKeySelective(toUpdateCreditHistory); | |||||
| } | |||||
| }); | |||||
| } | |||||
| @Transactional(rollbackFor = Exception.class) | @Transactional(rollbackFor = Exception.class) | ||||
| public void doFixVerifyCredit() { | public void doFixVerifyCredit() { | ||||
| // 1 获取券码 | // 1 获取券码 | ||||
| @@ -230,6 +162,12 @@ public class DataInitController extends BaseController { | |||||
| }); | }); | ||||
| } | } | ||||
| @Transactional(rollbackFor = Exception.class) | |||||
| public void addMsgModel(String context, Integer code) { | |||||
| IdWorker idWorker = IdWorker.get(); | |||||
| addBirthDayMsgModelToMall(EnumMsgModel.getEnum(code), idWorker, context); | |||||
| } | |||||
| /** | /** | ||||
| * 增加会员生日短信模板 | * 增加会员生日短信模板 | ||||
| */ | */ | ||||