From 9dfddb73a329af5afb72c47ba0fd500962f78321 Mon Sep 17 00:00:00 2001 From: jyy <935090232@qq.com> Date: Thu, 08 Apr 2021 19:13:59 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/score_shop' into score_shop --- zq-erp/src/main/resources/mybatis/mapper/activity/ActivitySignRecordDao.xml | 6 +- zq-erp/src/main/resources/templates/views/admin/activity/activity-sign-update.html | 6 ++ zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysWorktimeServiceImpl.java | 2 zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopActivitiesSignAction.java | 71 +++++++++++++++++++++-- zq-erp/src/main/resources/templates/views/admin/activity/activity-sign.html | 6 ++ zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java | 3 zq-erp/src/main/java/com/matrix/system/activity/dao/ActivitySignRecordDao.java | 7 +- zq-erp/src/main/resources/mybatis/mapper/hive/SysBusinessDataDao.xml | 66 ++++++++++++--------- 8 files changed, 121 insertions(+), 46 deletions(-) diff --git a/zq-erp/src/main/java/com/matrix/system/activity/dao/ActivitySignRecordDao.java b/zq-erp/src/main/java/com/matrix/system/activity/dao/ActivitySignRecordDao.java index ad74afb..5f13341 100644 --- a/zq-erp/src/main/java/com/matrix/system/activity/dao/ActivitySignRecordDao.java +++ b/zq-erp/src/main/java/com/matrix/system/activity/dao/ActivitySignRecordDao.java @@ -1,10 +1,11 @@ package com.matrix.system.activity.dao; -import org.apache.ibatis.annotations.Param; - import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.matrix.system.activity.entity.ActivitySignRecord; +import org.apache.ibatis.annotations.Param; + +import java.util.Date; /** * @description 签到记录表 @@ -14,6 +15,6 @@ public interface ActivitySignRecordDao extends BaseMapper<ActivitySignRecord>{ ActivitySignRecord selectOneByActIdAndUserIdLikesignTime(@Param("actId")long actId, - @Param("userId")Long userId, @Param("format")String format); + @Param("userId")Long userId, @Param("format")Date format); } \ No newline at end of file diff --git a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java index 4aeb01e..77f19f6 100644 --- a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java +++ b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java @@ -680,7 +680,7 @@ ShoppingGoods goods = shoppingGoodsDao.selectById(goodsId); flow.setFlowContent(goods.getName() + "等" + sourceOrder.getItems().size() + "件产品"); // 若是退款,则取负数 - if (Dictionary.ORDER_STATU_TK.equals(sourceOrder.getStatu())) { + if (SysOrder.ORDER_TYPE_REFUND == sourceOrder.getOrderType()) { flow.setFlowType(SysOrderFlow.FLOW_TYPE_REFUND); flow.setAmount(flow.getAmount().negate()); flow.setOrderId(sourceOrder.getOldOrderId()); @@ -1443,7 +1443,6 @@ sysOrder.setPayTime(now); sysOrder.setOrderNo(codeService.getRefundOrderNo()); sysOrder.setZkTotal(-sysOrder.getZkTotal()); - sysOrder.setOrderType(SysOrder.ORDER_TYPE_REFUND); //新增订单 sysOrderDao.insert(sysOrder); //插入明细 diff --git a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysWorktimeServiceImpl.java b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysWorktimeServiceImpl.java index d97fbba..77ccadb 100644 --- a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysWorktimeServiceImpl.java +++ b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysWorktimeServiceImpl.java @@ -97,7 +97,7 @@ @Override public boolean isInWorkTime(Long shopId, Date beginTime, Date endTime) { - if(beginTime==null){ + if(beginTime!=null){ Date minTime = findMinTime(shopId); Date maxTime = findMaxTime(shopId); minTime.setYear(beginTime.getYear()); diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopActivitiesSignAction.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopActivitiesSignAction.java index 912f35a..5149a5b 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopActivitiesSignAction.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopActivitiesSignAction.java @@ -24,6 +24,8 @@ import com.matrix.system.shopXcx.dao.ShopActivitiesDao; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; @@ -53,6 +55,9 @@ private ActivitySignRecordDao activitySignRecordDao; @ApiOperation(value = "获取签到基本信息", notes = "") + @ApiResponses({ + @ApiResponse(code = 200, message = "ok", response = SignBasicInfoVo.class) + }) @GetMapping(value = "/getSignBasicInfo") public AjaxResult getSignBasicInfo() { //获取登录人信息 @@ -75,7 +80,7 @@ signBasicInfoVo.setActivitySignAwardSetVos(activitySignAwardSetVos); //今日是否已经参与 - ActivitySignRecord activitySignRecord = activitySignRecordDao.selectOneByActIdAndUserIdLikesignTime(actId,userId,DateUtil.today()); + ActivitySignRecord activitySignRecord = activitySignRecordDao.selectOneByActIdAndUserIdLikesignTime(actId,userId,new Date()); if(ObjectUtil.isNotEmpty(activitySignRecord)) { signBasicInfoVo.setJoinState(SignBasicInfoVo.JOINSTATE_SIGN); }else { @@ -91,6 +96,9 @@ * */ @ApiOperation(value = "点击签到", notes = "") + @ApiResponses({ + @ApiResponse(code = 200, message = "ok", response = SignSuccessVo.class) + }) @PostMapping(value = "/clickSign") @Transactional public AjaxResult clickSign(@RequestBody ClickSignDTO clickSignDTO) { @@ -104,6 +112,7 @@ * 今日是否已经参与 * 新增签到记录表 * 判断累计连续签到天数是否+1 + * 是否已领取 * 查询是否有签到奖品 * 日常奖励和自定义奖品 */ @@ -118,25 +127,28 @@ return AjaxResult.buildFailInstance("活动未开始"); } //今日是否已经参与 - ActivitySignRecord activitySignRecord = activitySignRecordDao.selectOneByActIdAndUserIdLikesignTime(actId,userId,DateUtil.today()); + ActivitySignRecord activitySignRecord = activitySignRecordDao.selectOneByActIdAndUserIdLikesignTime(actId,userId,new Date()); if (ObjectUtil.isNotEmpty(activitySignRecord)) { return AjaxResult.buildFailInstance("今日用户已经签到成功"); } //前一天是否签到 Date date = new Date(); DateTime offsetDay = DateUtil.offsetDay(date, -1); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - ActivitySignRecord activitySignRecordOld = activitySignRecordDao.selectOneByActIdAndUserIdLikesignTime(actId,userId,sdf.format(offsetDay.getTime())); + ActivitySignRecord activitySignRecordOld = activitySignRecordDao.selectOneByActIdAndUserIdLikesignTime(actId,userId,offsetDay); ActivitySignRecord activitySignRecordAdd = new ActivitySignRecord(); activitySignRecordAdd.setCompanyId(companyId); + activitySignRecordAdd.setCreateBy(user.getName()); + activitySignRecordAdd.setCreateTime(new Date()); + activitySignRecordAdd.setUpdateBy(user.getName()); + activitySignRecordAdd.setUpdateTime(new Date()); activitySignRecordAdd.setActivityId(actId); activitySignRecordAdd.setSignTime(date); activitySignRecordAdd.setUserId(userId); - Integer cumulativeDay = activitySignRecordOld.getCumulativeDay(); if(ObjectUtil.isEmpty(activitySignRecordOld)) { //新增签到记录表,累计连续签到天数是1 activitySignRecordAdd.setCumulativeDay(1); }else { + Integer cumulativeDay = activitySignRecordOld.getCumulativeDay(); //新增签到记录表,累计连续签到天数是否+1 activitySignRecordAdd.setCumulativeDay(cumulativeDay+1); } @@ -160,20 +172,39 @@ activitySignReceiveRecord.setState(ActivitySignReceiveRecord.STATE_DONE); activitySignReceiveRecord.setActivityId(actId); activitySignReceiveRecord.setCompanyId(companyId); + activitySignReceiveRecord.setCreateBy(user.getName()); + activitySignReceiveRecord.setCreateTime(new Date()); + activitySignReceiveRecord.setUpdateBy(user.getName()); + activitySignReceiveRecord.setUpdateTime(new Date()); activitySignReceiveRecordDao.insert(activitySignReceiveRecord); signSuccessVo.setNormalAwardName(activitySignAwardSetNormal.getAwardName()); signSuccessVo.setNormalAwardImg(activitySignAwardSetNormal.getIntroduceImg()); } - + //获取当前累计天数 + int cumulativeDay = getCumulativeDay(actId, userId, date, 1); //自定义奖励 QueryWrapper<ActivitySignAwardSet> queryWrapperCumulativeDay = new QueryWrapper<>(); queryWrapperCumulativeDay.eq("award_rule",ActivitySignAwardSet.AWARDRULE_CUMULATIVEDAY); - queryWrapperCumulativeDay.eq("cumulative_day",activitySignRecordAdd.getCumulativeDay()); + queryWrapperCumulativeDay.eq("cumulative_day",cumulativeDay); queryWrapperCumulativeDay.eq("company_id",companyId); queryWrapperCumulativeDay.eq("activity_id",actId); ActivitySignAwardSet activitySignAwardSetCumulativeDay = activitySignAwardSetDao.selectOne(queryWrapperCumulativeDay); if(ObjectUtil.isNotEmpty(activitySignAwardSetCumulativeDay)) { + //是否已领取 + Long id = activitySignAwardSetCumulativeDay.getId(); + QueryWrapper<ActivitySignReceiveRecord> queryWrapperActivitySignReceiveRecord = new QueryWrapper<>(); + queryWrapperActivitySignReceiveRecord.eq("award_id", id); + queryWrapperActivitySignReceiveRecord.eq("company_id", companyId); + queryWrapperActivitySignReceiveRecord.eq("activity_id", actId); + queryWrapperActivitySignReceiveRecord.eq("user_id", userId); + ActivitySignReceiveRecord activitySignReceiveRecordDone = activitySignReceiveRecordDao.selectOne(queryWrapperActivitySignReceiveRecord); + if (ObjectUtil.isNotEmpty(activitySignReceiveRecordDone)) { + String awardNameCumulativeDay = activitySignAwardSetCumulativeDay.getAwardName(); + AjaxResult ajaxResult = AjaxResult.buildSuccessInstance(awardNameCumulativeDay+"已经领取过了"); + ajaxResult.setData(signSuccessVo); + return ajaxResult; + } //新增奖品领取记录 ActivitySignReceiveRecord activitySignReceiveRecord = new ActivitySignReceiveRecord(); activitySignReceiveRecord.setUserId(userId); @@ -182,6 +213,10 @@ activitySignReceiveRecord.setActivityId(actId); activitySignReceiveRecord.setCompanyId(companyId); activitySignReceiveRecord.setState(ActivitySignReceiveRecord.STATE_DONE); + activitySignReceiveRecord.setCreateBy(user.getName()); + activitySignReceiveRecord.setCreateTime(new Date()); + activitySignReceiveRecord.setUpdateBy(user.getName()); + activitySignReceiveRecord.setUpdateTime(new Date()); /** * 奖项类型(1:自定义产品2:积分3:优惠券4:店铺商品) * @@ -223,7 +258,7 @@ signSuccessVo.setScoreCnt(activitySignAwardSetCumulativeDay.getScoreCnt()); } //3:优惠券 - if(ActivitySignAwardSet.AWARDTYPE_SCORE == activitySignAwardSetCumulativeDay.getAwardType()) { + if(ActivitySignAwardSet.AWARDTYPE_COUPON == activitySignAwardSetCumulativeDay.getAwardType()) { signSuccessVo.setCouponName(activitySignAwardSetCumulativeDay.getCouponName()); } activitySignReceiveRecordDao.insert(activitySignReceiveRecord); @@ -233,4 +268,24 @@ ajaxResult.setData(signSuccessVo); return ajaxResult; } + /** + * 获取累计签到天数 + * @param actId + * @param userId + * @param date + * @return + */ + public int getCumulativeDay(long actId, long userId,Date date, int i) { + ActivitySignRecord activitySignRecordOld = activitySignRecordDao.selectOneByActIdAndUserIdLikesignTime(actId,userId,date); + if(ObjectUtil.isEmpty(activitySignRecordOld)) { + return i; + } + i++; + DateTime offsetDay = DateUtil.offsetDay(date, -i); + return getCumulativeDay(actId,userId,offsetDay,i); + } + + + + } diff --git a/zq-erp/src/main/resources/mybatis/mapper/activity/ActivitySignRecordDao.xml b/zq-erp/src/main/resources/mybatis/mapper/activity/ActivitySignRecordDao.xml index 59fe364..ad83bc6 100644 --- a/zq-erp/src/main/resources/mybatis/mapper/activity/ActivitySignRecordDao.xml +++ b/zq-erp/src/main/resources/mybatis/mapper/activity/ActivitySignRecordDao.xml @@ -9,9 +9,9 @@ FROM activity_sign_record a where - a.actId = #{actId} - and a.open_id = #{userId} - and a.sign_time like concat('%',#{format},'%') + a.activity_id = #{actId} + and a.user_id = #{userId} + and a.sign_time like concat('%',DATE(#{format}),'%') </select> </mapper> \ No newline at end of file diff --git a/zq-erp/src/main/resources/mybatis/mapper/hive/SysBusinessDataDao.xml b/zq-erp/src/main/resources/mybatis/mapper/hive/SysBusinessDataDao.xml index 8100408..2cfc1a1 100644 --- a/zq-erp/src/main/resources/mybatis/mapper/hive/SysBusinessDataDao.xml +++ b/zq-erp/src/main/resources/mybatis/mapper/hive/SysBusinessDataDao.xml @@ -624,63 +624,69 @@ select #{item.beginTime} dataTime, (select shop_short_name from sys_shop_info where id=#{shopId}) shopName, - (select IFNULL(sum(amount),0) from sys_order_flow - where <![CDATA[ create_time > #{item.beginTime} and create_time < #{item.endTime}]]> and pay_method!='欠款' + (select IFNULL(sum(a.amount),0) from sys_order_flow a + inner join sys_order b on a.order_id=b.id and b.statu!='已取消' + where <![CDATA[ a.create_time > #{item.beginTime} and a.create_time < #{item.endTime}]]> and a.pay_method!='欠款' <if test="shopId != null"> - and shop_id=#{shopId} + and a.shop_id=#{shopId} </if> <if test="companyId != null"> - and company_id=#{companyId} + and a.company_id=#{companyId} </if> )totalPay, - (select IFNULL(sum(amount),0) from sys_order_flow - where pay_method not in ('储值卡', '欠款') and flow_type != '退款' and <![CDATA[ create_time > #{item.beginTime} and create_time < #{item.endTime}]]> + (select IFNULL(sum(a.amount),0) from sys_order_flow a + inner join sys_order b on a.order_id=b.id and b.statu!='已取消' + where a.pay_method not in ('储值卡', '欠款') and a.flow_type != '退款' and <![CDATA[ a.create_time > #{item.beginTime} and a.create_time < #{item.endTime}]]> <if test="shopId != null"> - and shop_id=#{shopId} + and a.shop_id=#{shopId} </if> <if test="companyId != null"> - and company_id=#{companyId} + and a.company_id=#{companyId} </if> ) cashPay, - (select IFNULL(sum(amount),0) from sys_order_flow - where pay_method = '储值卡' and flow_type != '退款' and <![CDATA[ create_time > #{item.beginTime} and create_time < #{item.endTime}]]> + (select IFNULL(sum(a.amount),0) from sys_order_flow a + inner join sys_order b on a.order_id=b.id and b.statu!='已取消' + where a.pay_method = '储值卡' and a.flow_type != '退款' and <![CDATA[ a.create_time > #{item.beginTime} and a.create_time < #{item.endTime}]]> <if test="shopId != null"> - and shop_id=#{shopId} + and a.shop_id=#{shopId} </if> <if test="companyId != null"> - and company_id=#{companyId} + and a.company_id=#{companyId} </if> ) cardPay, - (select IFNULL(sum(amount),0) from sys_order_flow - where pay_method = '欠款' and <![CDATA[ create_time > #{item.beginTime} and create_time < #{item.endTime}]]> + (select IFNULL(sum(a.amount),0) from sys_order_flow a + inner join sys_order b on a.order_id=b.id and b.statu!='已取消' + where a.pay_method = '欠款' and <![CDATA[ a.create_time > #{item.beginTime} and a.create_time < #{item.endTime}]]> <if test="shopId != null"> - and shop_id=#{shopId} + and a.shop_id=#{shopId} </if> <if test="companyId != null"> - and company_id=#{companyId} + and a.company_id=#{companyId} </if> ) arrearsPay, - (select IFNULL(sum(amount),0) from sys_order_flow - where pay_method not in ('储值卡', '欠款') and flow_type = '退款' and <![CDATA[ create_time > #{item.beginTime} and create_time < #{item.endTime}]]> + (select IFNULL(sum(a.amount),0) from sys_order_flow a + inner join sys_order b on a.order_id=b.id and b.statu!='已取消' + where a.pay_method not in ('储值卡', '欠款') and a.flow_type = '退款' and <![CDATA[ a.create_time > #{item.beginTime} and a.create_time < #{item.endTime}]]> <if test="shopId != null"> - and shop_id=#{shopId} + and a.shop_id=#{shopId} </if> <if test="companyId != null"> - and company_id=#{companyId} + and a.company_id=#{companyId} </if> ) refundCashPay, - (select IFNULL(sum(amount),0) from sys_order_flow - where pay_method in ('储值卡') and flow_type = '退款' and <![CDATA[ create_time > #{item.beginTime} and create_time < #{item.endTime}]]> + (select IFNULL(sum(a.amount),0) from sys_order_flow a + inner join sys_order b on a.order_id=b.id and b.statu!='已取消' + where a.pay_method in ('储值卡') and a.flow_type = '退款' and <![CDATA[ a.create_time > #{item.beginTime} and a.create_time < #{item.endTime}]]> <if test="shopId != null"> - and shop_id=#{shopId} + and a.shop_id=#{shopId} </if> <if test="companyId != null"> - and company_id=#{companyId} + and a.company_id=#{companyId} </if> ) refundCardPay, (select IFNULL(sum(zk_price*count),0) from sys_order_item a inner join shopping_goods b on a.goods_id=b.id - inner join sys_order c on a.ORDER_ID=c.id + inner join sys_order c on a.ORDER_ID=c.id and c.statu!='已取消' where b.good_type='家居产品' and <![CDATA[ c.pay_time > #{item.beginTime} and c.pay_time < #{item.endTime}]]> <if test="shopId != null"> and c.shop_id=#{shopId} @@ -691,7 +697,7 @@ ) productAchieve, (select IFNULL(sum(zk_price*count),0) from sys_order_item a inner join shopping_goods b on a.goods_id=b.id - inner join sys_order c on a.ORDER_ID=c.id + inner join sys_order c on a.ORDER_ID=c.id and c.statu!='已取消' where b.good_type!='家居产品' and <![CDATA[ c.pay_time > #{item.beginTime} and c.pay_time < #{item.endTime}]]> <if test="shopId != null"> and c.shop_id=#{shopId} @@ -700,12 +706,14 @@ and c.company_id=#{companyId} </if> ) cardAchieve, - (select IFNULL(sum(amount),0) from sys_order_flow where flow_type = '还款' and <![CDATA[ create_time > #{item.beginTime} and create_time < #{item.endTime}]]> + (select IFNULL(sum(a.amount),0) from sys_order_flow a + inner join sys_order b on a.order_id=b.id and b.statu!='已取消' + where a.flow_type = '还款' and <![CDATA[ a.create_time > #{item.beginTime} and a.create_time < #{item.endTime}]]> <if test="shopId != null"> - and shop_id=#{shopId} + and a.shop_id=#{shopId} </if> <if test="companyId != null"> - and company_id=#{companyId} + and a.company_id=#{companyId} </if> ) refund, (select IFNULL(count(1),0) from sys_order diff --git a/zq-erp/src/main/resources/templates/views/admin/activity/activity-sign-update.html b/zq-erp/src/main/resources/templates/views/admin/activity/activity-sign-update.html index 1780ed7..8c6e40b 100644 --- a/zq-erp/src/main/resources/templates/views/admin/activity/activity-sign-update.html +++ b/zq-erp/src/main/resources/templates/views/admin/activity/activity-sign-update.html @@ -892,9 +892,15 @@ let activitySignAwardSets = []; for (let i = 0; i < _this.editableTabs.length; i++) { let prize = _this.editableTabs[i].content; + let name = _this.editableTabs[i].title; + let awardRule = 2; + if(name == "签到日常奖励"){ + awardRule = 1; + } let activitySignAwardSet = { id: prize.id, cumulativeDay: prize.cumulativeDay, + awardRule: awardRule, awardType: prize.awardType, awardName: prize.awardName, introduceImg: prize.introduceImg, diff --git a/zq-erp/src/main/resources/templates/views/admin/activity/activity-sign.html b/zq-erp/src/main/resources/templates/views/admin/activity/activity-sign.html index 5460aeb..a134b2f 100644 --- a/zq-erp/src/main/resources/templates/views/admin/activity/activity-sign.html +++ b/zq-erp/src/main/resources/templates/views/admin/activity/activity-sign.html @@ -822,8 +822,14 @@ let activitySignAwardSets = []; for (let i = 0; i < _this.editableTabs.length; i++) { let prize = _this.editableTabs[i].content; + let name = _this.editableTabs[i].title; + let awardRule = 2; + if(name == "签到日常奖励"){ + awardRule = 1; + } let activitySignAwardSet = { cumulativeDay: prize.cumulativeDay, + awardRule: awardRule, awardType: prize.awardType, awardName: prize.awardName, introduceImg: prize.introduceImg, -- Gitblit v1.9.1