| @@ -43,8 +43,8 @@ public class DaliyAmountSchedule { | |||||
| @Scheduled(cron = "0 0 23 * * ?") // 每天晚上11点盘点 | |||||
| //@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 | |||||
| //@Scheduled(cron = "0 0 1 * * ?") // 每天凌晨1点盘点前一天的数据 | |||||
| @Scheduled(cron = "*/30 * * * * ?") // 测试10秒中一次 | |||||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | ||||
| public void daliyAmountSchedule() { | public void daliyAmountSchedule() { | ||||
| @@ -69,20 +69,22 @@ public class DaliyAmountSchedule { | |||||
| } | } | ||||
| for (int j=0; j < merchantList.size(); j++) { | for (int j=0; j < merchantList.size(); j++) { | ||||
| Calendar cal = Calendar.getInstance(); | |||||
| merchant = merchantList.get(j); | merchant = merchantList.get(j); | ||||
| cal.setTime(new Date()); | |||||
| cal.set(Calendar.HOUR_OF_DAY, 0); | |||||
| cal.set(Calendar.MINUTE, 0); | |||||
| cal.set(Calendar.SECOND, 0); | |||||
| cal.set(Calendar.MILLISECOND, 0); | |||||
| Date endDate = cal.getTime(); | |||||
| cal.add(Calendar.DAY_OF_YEAR, -1); | |||||
| Date startDate = cal.getTime(); | |||||
| Map dateMap = new HashMap(); | Map dateMap = new HashMap(); | ||||
| SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd"); | |||||
| String dateString = fmt.format(new Date()); | |||||
| Date startDate = null; | |||||
| try { | |||||
| startDate = fmt.parse(dateString); | |||||
| } catch (ParseException e) { | |||||
| logger.error("Parse date string failed"); | |||||
| continue; | |||||
| } | |||||
| dateMap.put("startDate", startDate); | dateMap.put("startDate", startDate); | ||||
| dateMap.put("endDate", new Date()); | |||||
| dateMap.put("endDate", endDate); | |||||
| dateMap.put("merchantID",merchant.getId()); | dateMap.put("merchantID",merchant.getId()); | ||||
| List<WxCouponOrder> list = wxCouponOrderMapper.findListOfOrderedByDate(dateMap); | List<WxCouponOrder> list = wxCouponOrderMapper.findListOfOrderedByDate(dateMap); | ||||
| @@ -96,30 +98,17 @@ public class DaliyAmountSchedule { | |||||
| "from " + startDate + " to " + new Date() +"\n" + | "from " + startDate + " to " + new Date() +"\n" + | ||||
| "TOTAL ORDER=" + total_price); | "TOTAL ORDER=" + total_price); | ||||
| Date now = new Date(); | |||||
| Calendar cal = Calendar.getInstance(); | |||||
| cal.setTime(now); // 将时分秒,毫秒域清零 | |||||
| cal.set(Calendar.HOUR_OF_DAY, 0); | |||||
| cal.set(Calendar.MINUTE, 0); | |||||
| cal.set(Calendar.SECOND, 0); | |||||
| cal.set(Calendar.MILLISECOND, 0); | |||||
| now = cal.getTime(); | |||||
| WxDateAmountRecord dateAmountRecord = new WxDateAmountRecord(); | WxDateAmountRecord dateAmountRecord = new WxDateAmountRecord(); | ||||
| dateAmountRecord.setId(IdWorker.get().nextId()); | |||||
| dateAmountRecord.setCreateDate(new Date()); | |||||
| dateAmountRecord.setUpdateDate(new Date()); | |||||
| dateAmountRecord.setPayPrice(total_price); | dateAmountRecord.setPayPrice(total_price); | ||||
| dateAmountRecord.setMerchantId(merchant.getId()); | dateAmountRecord.setMerchantId(merchant.getId()); | ||||
| dateAmountRecord.setTenantId(merchant.getTenantId()); | dateAmountRecord.setTenantId(merchant.getTenantId()); | ||||
| dateAmountRecord.setType(EnumDateAmtType.PAY_RECORD.getCode()); | dateAmountRecord.setType(EnumDateAmtType.PAY_RECORD.getCode()); | ||||
| dateAmountRecord.setDate(now); | |||||
| dateAmountRecord.setDate(startDate); | |||||
| dateAmountRecord.setDayOfWeek(cal.get(Calendar.DAY_OF_WEEK)); | dateAmountRecord.setDayOfWeek(cal.get(Calendar.DAY_OF_WEEK)); | ||||
| dateAmountRecord.setMonth(cal.get(Calendar.MONTH)); | dateAmountRecord.setMonth(cal.get(Calendar.MONTH)); | ||||
| dateAmountRecord.setWeekOfYear(cal.get(Calendar.WEEK_OF_YEAR)); | dateAmountRecord.setWeekOfYear(cal.get(Calendar.WEEK_OF_YEAR)); | ||||
| wxDateAmountRecordService.saveDaliyAmount(dateAmountRecord); | |||||
| wxDateAmountRecordService.saveAmount(dateAmountRecord); | |||||
| list= wxCouponOrderMapper.findListOfVerifiedByDate(dateMap); | list= wxCouponOrderMapper.findListOfVerifiedByDate(dateMap); | ||||
| logger.info("find " + list.size() + " coupon order from " + startDate + " to " + new Date()); | logger.info("find " + list.size() + " coupon order from " + startDate + " to " + new Date()); | ||||
| @@ -132,10 +121,9 @@ public class DaliyAmountSchedule { | |||||
| "from " + startDate + " to " + new Date() +"\n" + | "from " + startDate + " to " + new Date() +"\n" + | ||||
| "TOTAL VERIFIED=" + total_price); | "TOTAL VERIFIED=" + total_price); | ||||
| dateAmountRecord.setId(IdWorker.get().nextId()); | |||||
| dateAmountRecord.setPayPrice(total_price); | dateAmountRecord.setPayPrice(total_price); | ||||
| dateAmountRecord.setType(EnumDateAmtType.VERIFY_RECORD.getCode()); | dateAmountRecord.setType(EnumDateAmtType.VERIFY_RECORD.getCode()); | ||||
| wxDateAmountRecordService.saveDaliyAmount(dateAmountRecord); | |||||
| wxDateAmountRecordService.saveAmount(dateAmountRecord); | |||||
| } | } | ||||
| } | } | ||||
| @@ -5,6 +5,8 @@ import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.WxDateAmountRecord; | import com.iformall.domain.po.WxDateAmountRecord; | ||||
| import com.iformall.domain.po.WxMerchantBUser; | import com.iformall.domain.po.WxMerchantBUser; | ||||
| import com.iformall.domain.vo.AmountRecordVo; | import com.iformall.domain.vo.AmountRecordVo; | ||||
| import com.iformall.enums.EnumCouponOrderStatus; | |||||
| import com.iformall.enums.EnumDateAmtType; | |||||
| import com.iformall.service.WxDateAmountRecordService; | import com.iformall.service.WxDateAmountRecordService; | ||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| @@ -34,16 +36,16 @@ public class WxDateAmountRecordController extends BaseController { | |||||
| @ApiOperation("首页查询交易金额记录接口") | @ApiOperation("首页查询交易金额记录接口") | ||||
| @GetMapping("listOrder") | @GetMapping("listOrder") | ||||
| public ResultData listOrder() { | public ResultData listOrder() { | ||||
| return list(0); | |||||
| return list(EnumDateAmtType.PAY_RECORD.getCode()); | |||||
| } | } | ||||
| @ApiOperation("首页查询核销金额记录接口") | @ApiOperation("首页查询核销金额记录接口") | ||||
| @GetMapping("listVerified") | @GetMapping("listVerified") | ||||
| public ResultData listVerified() { | public ResultData listVerified() { | ||||
| return list(1); | |||||
| return list(EnumDateAmtType.VERIFY_RECORD.getCode()); | |||||
| } | } | ||||
| private ResultData list(int verified) { | |||||
| private ResultData list(int status) { | |||||
| List<AmountRecordVo> list = new ArrayList<>(); | List<AmountRecordVo> list = new ArrayList<>(); | ||||
| @@ -51,7 +53,7 @@ public class WxDateAmountRecordController extends BaseController { | |||||
| WxMerchantBUser u = getUser(); | WxMerchantBUser u = getUser(); | ||||
| temp.setTenantId(u.getTenantId()); | temp.setTenantId(u.getTenantId()); | ||||
| temp.setMerchantId(u.getMerchantId()); | temp.setMerchantId(u.getMerchantId()); | ||||
| temp.setType(verified); | |||||
| temp.setType(status); | |||||
| temp.setSortColumns(WxDateAmountRecord.Field.UpdateDate_DESC); | temp.setSortColumns(WxDateAmountRecord.Field.UpdateDate_DESC); | ||||
| SimpleDateFormat fmt = new SimpleDateFormat("MM/dd"); | SimpleDateFormat fmt = new SimpleDateFormat("MM/dd"); | ||||
| @@ -64,7 +66,7 @@ public class WxDateAmountRecordController extends BaseController { | |||||
| AmountRecordVo vo = new AmountRecordVo(); | AmountRecordVo vo = new AmountRecordVo(); | ||||
| vo.setAmount(wxDateAmountRecord.getPayPrice()); | vo.setAmount(wxDateAmountRecord.getPayPrice()); | ||||
| vo.setAmountDetail(wxDateAmountRecord); | vo.setAmountDetail(wxDateAmountRecord); | ||||
| vo.setMouthAndDate(fmt.format(wxDateAmountRecord.getUpdateDate())); | |||||
| vo.setMouthAndDate(fmt.format(wxDateAmountRecord.getDate())); | |||||
| list.add(vo); | list.add(vo); | ||||
| } | } | ||||
| Collections.reverse(list); | Collections.reverse(list); | ||||
| @@ -36,22 +36,11 @@ public interface WxDateAmountRecordService { | |||||
| * @param id | * @param id | ||||
| */ | */ | ||||
| void deleteById(Long id); | void deleteById(Long id); | ||||
| /** | |||||
| * 修改交易核销 | |||||
| * @param tenantId 租户id | |||||
| * @param merchantId 商户id | |||||
| * @param type 类型 0 交易记录 1.核销记录 | |||||
| * @param payPrice 金额 | |||||
| * @return | |||||
| */ | |||||
| int updateAmount(String tenantId,Long merchantId | |||||
| ,Integer type,Integer payPrice); | |||||
| /** | /** | ||||
| * 记录每日交易核销总额 | * 记录每日交易核销总额 | ||||
| */ | */ | ||||
| void saveDaliyAmount(WxDateAmountRecord amount); | |||||
| void saveAmount(WxDateAmountRecord amount); | |||||
| } | } | ||||
| @@ -138,7 +138,6 @@ public class WxCUserTagsServiceImpl implements WxCUserTagsService { | |||||
| //**************************************************自动打标逻辑代码 ************************************************************* | //**************************************************自动打标逻辑代码 ************************************************************* | ||||
| static List<WxTagsGroup> tagGroups = null; | |||||
| //打标 | //打标 | ||||
| private List<WxTags> assign(WxCUserBasicInfo user, EnumTag tag){ | private List<WxTags> assign(WxCUserBasicInfo user, EnumTag tag){ | ||||
| @@ -47,34 +47,9 @@ public class WxDateAmountRecordServiceImpl implements WxDateAmountRecordService | |||||
| wxDateAmountRecordMapper.deleteByPrimaryKey(id); | wxDateAmountRecordMapper.deleteByPrimaryKey(id); | ||||
| } | } | ||||
| @Override | |||||
| public int updateAmount(String tenantId, Long merchantId, Integer type, Integer payPrice) { | |||||
| Date now = new Date(); | |||||
| Calendar cal1 = Calendar.getInstance(); | |||||
| cal1.setTime(now); // 将时分秒,毫秒域清零 | |||||
| cal1.set(Calendar.HOUR_OF_DAY, 0); | |||||
| cal1.set(Calendar.MINUTE, 0); | |||||
| cal1.set(Calendar.SECOND, 0); | |||||
| cal1.set(Calendar.MILLISECOND, 0); | |||||
| now = cal1.getTime(); | |||||
| WxDateAmountRecord r = new WxDateAmountRecord(); | |||||
| r.setDate(now); | |||||
| r.setTenantId(tenantId); | |||||
| r.setMerchantId(merchantId); | |||||
| r.setType(type); | |||||
| List<WxDateAmountRecord> list = wxDateAmountRecordMapper.findList(r); | |||||
| r.setPayPrice(payPrice); | |||||
| if(!list.isEmpty()) {//今天没数据就新增一条 | |||||
| r.setDayOfWeek(cal1.get(Calendar.DAY_OF_WEEK)); | |||||
| r.setMonth(cal1.get(Calendar.MONTH)); | |||||
| r.setWeekOfYear(cal1.get(Calendar.WEEK_OF_YEAR)); | |||||
| return wxDateAmountRecordMapper.insertSelective(r); | |||||
| } | |||||
| return wxDateAmountRecordMapper.updateAmount(r); | |||||
| } | |||||
| @Override | @Override | ||||
| public void saveDaliyAmount(WxDateAmountRecord amount) { | |||||
| public void saveAmount(WxDateAmountRecord amount) { | |||||
| WxDateAmountRecord record = new WxDateAmountRecord(); | WxDateAmountRecord record = new WxDateAmountRecord(); | ||||
| record.setDate(amount.getDate()); | record.setDate(amount.getDate()); | ||||
| @@ -89,6 +64,10 @@ public class WxDateAmountRecordServiceImpl implements WxDateAmountRecordService | |||||
| list.get(0).setUpdateDate(new Date()); | list.get(0).setUpdateDate(new Date()); | ||||
| wxDateAmountRecordMapper.updateByPrimaryKeySelective(list.get(0)); | wxDateAmountRecordMapper.updateByPrimaryKeySelective(list.get(0)); | ||||
| }else{ | }else{ | ||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| amount.setId(idWorker.nextId()); | |||||
| amount.setUpdateDate(new Date()); | |||||
| amount.setCreateDate(new Date()); | |||||
| wxDateAmountRecordMapper.insertSelective(amount); | wxDateAmountRecordMapper.insertSelective(amount); | ||||
| } | } | ||||
| } | } | ||||