From 110a99baa82a748bee993ad01ca03370c9dc0cf2 Mon Sep 17 00:00:00 2001 From: Helius <wangdoubleone@gmail.com> Date: Mon, 01 Nov 2021 17:41:41 +0800 Subject: [PATCH] fix service and order numOfPeople --- zq-erp/src/main/java/com/matrix/system/hive/dao/SysOrderDao.java | 3 + zq-erp/src/main/java/com/matrix/system/hive/service/SysOrderService.java | 3 + zq-erp/src/main/resources/mybatis/mapper/hive/SysOrderDao.xml | 6 ++ zq-erp/src/main/resources/templates/views/admin/hive/beautySalon/vip.html | 1 zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysVipInfoServiceImpl.java | 7 +++ zq-erp/src/main/java/com/matrix/system/app/action/ApiSettingAction.java | 14 +++++-- zq-erp/src/main/java/com/matrix/system/hive/action/VipInfoController.java | 1 zq-erp/src/main/java/com/matrix/system/hive/bean/SysVipInfo.java | 4 +- zq-erp/src/main/java/com/matrix/system/hive/service/imp/AchieveNewServiceImpl.java | 50 ++++++++++++++++++++----- zq-erp/src/main/resources/config/application.properties | 6 ++ zq-erp/src/main/java/com/matrix/system/app/action/ApiCommonAction.java | 7 +++ zq-erp/src/main/java/com/matrix/system/app/vo/VipInfoVo.java | 10 +++++ zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java | 5 ++ 13 files changed, 97 insertions(+), 20 deletions(-) diff --git a/zq-erp/src/main/java/com/matrix/system/app/action/ApiCommonAction.java b/zq-erp/src/main/java/com/matrix/system/app/action/ApiCommonAction.java index f3e8702..44a65ca 100644 --- a/zq-erp/src/main/java/com/matrix/system/app/action/ApiCommonAction.java +++ b/zq-erp/src/main/java/com/matrix/system/app/action/ApiCommonAction.java @@ -68,12 +68,15 @@ @Value("${static_resource_url}") private String nginxUrl; + @Value("${login_public_key}") + private String publicKey; + @ApiOperation(value = "登陆接口", notes = "手机端登陆接口") @ApiResponses({ @ApiResponse(code = 200, message = "OK", response = UserInfoVo.class) }) @PostMapping(value = "/login") - public AjaxResult login(@RequestBody @Validated LoginDto loginDto) { + public AjaxResult login(@RequestBody @Validated LoginDto loginDto) throws Exception { SysUsers user = new SysUsers(); user.setSuAccount(loginDto.getUsername()); @@ -97,10 +100,12 @@ userInfoVo.setRoleName(user.getRoleName()); userInfoVo.setPhoto(user.getSuPhoto()); + String sb = token + "_1" + "_/api/vip/findVipInfoById/972"; AjaxResult result = AjaxResult.buildSuccessInstance("登陆成功"); authorityManager.initUserPower(result,user); result.putInMap("user", userInfoVo); result.putInMap("token", token); + result.putInMap("rasToken", RSAUtils.encryptByPublicKey(sb, publicKey)); return result; } diff --git a/zq-erp/src/main/java/com/matrix/system/app/action/ApiSettingAction.java b/zq-erp/src/main/java/com/matrix/system/app/action/ApiSettingAction.java index 312228d..5827bb1 100644 --- a/zq-erp/src/main/java/com/matrix/system/app/action/ApiSettingAction.java +++ b/zq-erp/src/main/java/com/matrix/system/app/action/ApiSettingAction.java @@ -12,10 +12,7 @@ import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.CrossOrigin; -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.*; /** * @author jyy @@ -44,4 +41,13 @@ return result; } + @ApiOperation(value = "根据code获取配置", notes = "根据code获取配置") + @GetMapping(value = "/findAppSettingsByCode") + public AjaxResult findAppSettingsByCode(String code) { + SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); + AjaxResult result = AjaxResult.buildSuccessInstance("查询成功"); + result.putInMap(code, busParameterSettingsDao.selectCompanyParamByCode(code,user.getCompanyId())); + return result; + } + } diff --git a/zq-erp/src/main/java/com/matrix/system/app/vo/VipInfoVo.java b/zq-erp/src/main/java/com/matrix/system/app/vo/VipInfoVo.java index 325c469..1934aaf 100644 --- a/zq-erp/src/main/java/com/matrix/system/app/vo/VipInfoVo.java +++ b/zq-erp/src/main/java/com/matrix/system/app/vo/VipInfoVo.java @@ -42,6 +42,16 @@ @ApiModelProperty(value = "累计消费") private BigDecimal totalShopping; + @ApiModelProperty(value = "欠款") + private BigDecimal arrears; + + public BigDecimal getArrears() { + return arrears; + } + + public void setArrears(BigDecimal arrears) { + this.arrears = arrears; + } public String getPhoto() { return photo; diff --git a/zq-erp/src/main/java/com/matrix/system/hive/action/VipInfoController.java b/zq-erp/src/main/java/com/matrix/system/hive/action/VipInfoController.java index 9edf94f..fed9f78 100644 --- a/zq-erp/src/main/java/com/matrix/system/hive/action/VipInfoController.java +++ b/zq-erp/src/main/java/com/matrix/system/hive/action/VipInfoController.java @@ -261,6 +261,7 @@ vips.get(0).setLabels(sysVipLabelDao.selectByVipId(vips.get(0).getId())); vips.get(0).setAge(DateUtil.getAgeForBirthDay(vips.get(0).getBirthday1())); vips.get(0).setBalance(moneyCardUseDao.selectVipCardTotalMoney(vips.get(0).getId())); + vips.get(0).setArrears(sysOrderService.findVipArrearsByVipId(vips.get(0).getId())); AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, vips, 0); return result; } else { diff --git a/zq-erp/src/main/java/com/matrix/system/hive/bean/SysVipInfo.java b/zq-erp/src/main/java/com/matrix/system/hive/bean/SysVipInfo.java index 72f4119..09224d4 100644 --- a/zq-erp/src/main/java/com/matrix/system/hive/bean/SysVipInfo.java +++ b/zq-erp/src/main/java/com/matrix/system/hive/bean/SysVipInfo.java @@ -9,6 +9,7 @@ import org.springframework.format.annotation.DateTimeFormat; import java.io.Serializable; +import java.math.BigDecimal; import java.util.Date; import java.util.List; @@ -437,8 +438,7 @@ private String name; + private BigDecimal arrears; - - } \ No newline at end of file diff --git a/zq-erp/src/main/java/com/matrix/system/hive/dao/SysOrderDao.java b/zq-erp/src/main/java/com/matrix/system/hive/dao/SysOrderDao.java index c052f28..22ef160 100644 --- a/zq-erp/src/main/java/com/matrix/system/hive/dao/SysOrderDao.java +++ b/zq-erp/src/main/java/com/matrix/system/hive/dao/SysOrderDao.java @@ -9,6 +9,7 @@ import com.matrix.system.shopXcx.api.vo.ErpOrderDetailVo; import org.apache.ibatis.annotations.Param; +import java.math.BigDecimal; import java.util.Date; import java.util.List; @@ -54,4 +55,6 @@ List<ErpOrderDetailVo> selectErpOrderList(ErpOrderListDto erpOrderListDto); ErpOrderDetailVo findUserOrderById(Long orderId); + + BigDecimal selectArrearsByVipId(Long vipId); } \ No newline at end of file diff --git a/zq-erp/src/main/java/com/matrix/system/hive/service/SysOrderService.java b/zq-erp/src/main/java/com/matrix/system/hive/service/SysOrderService.java index 6e0e060..2be2912 100644 --- a/zq-erp/src/main/java/com/matrix/system/hive/service/SysOrderService.java +++ b/zq-erp/src/main/java/com/matrix/system/hive/service/SysOrderService.java @@ -12,6 +12,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.servlet.http.HttpSession; +import java.math.BigDecimal; import java.util.List; /** @@ -142,4 +143,6 @@ List<RankingVo> findApiShopAchieveRanking(SysOrder sysOrder); + BigDecimal findVipArrearsByVipId(Long vipId); + } \ No newline at end of file diff --git a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/AchieveNewServiceImpl.java b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/AchieveNewServiceImpl.java index afec062..ff89cae 100644 --- a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/AchieveNewServiceImpl.java +++ b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/AchieveNewServiceImpl.java @@ -174,8 +174,7 @@ boolean flag = projServicesService.skipServiceOrderStep(Dictionary.SALE_MAN_IS_CONSUME_ACHIEVE); - - + Set<Long> beautyIds = new HashSet<>(); for (SysBeauticianState beauticianState : beauticianStateList) { // 是否第一次计算改美疗师 boolean isFirst = true; @@ -222,13 +221,13 @@ // } } - List<AchieveNew> beautyList = achieveNewDao.selectBeautyManAchieveList(beauticianState.getStaffId(), projServices.getVipId(), new Date()); - if (CollUtil.isEmpty(beautyList)) { - achieveNew.setNumberOfPeople(1D / size); - } else { - achieveNew.setNumberOfPeople(1D / (size + beautyList.size())); - achieveNewDao.updateAchieveNumOfPeople(beautyList, achieveNew.getNumberOfPeople()); - } +// List<AchieveNew> beautyList = achieveNewDao.selectBeautyManAchieveList(beauticianState.getStaffId(), projServices.getVipId(), new Date()); +// if (CollUtil.isEmpty(beautyList)) { +// achieveNew.setNumberOfPeople(1D / size); +// } else { +// achieveNew.setNumberOfPeople(1D / (size + beautyList.size())); +// achieveNewDao.updateAchieveNumOfPeople(beautyList, achieveNew.getNumberOfPeople()); +// } achieveNew.setProjNum(1); if (StringUtils.isNotBlank(beauticianState.getExtract())) { @@ -244,11 +243,14 @@ achieveNew.setProjTime(beauticianState.getExcTime()); isFirst = false; } + + beautyIds.add(achieveNew.getBeaultId()); achieveNewList.add(achieveNew); } if (CollectionUtils.isNotEmpty(achieveNewList)) { achieveNewDao.batchInsert(achieveNewList); + achieveNumOfPeople(beautyIds, projServices.getVipId()); } } @@ -297,9 +299,31 @@ } } + /** + * + * 合并订单与服务单人头逻辑,即每一个客户对美疗师/顾问来说,每一天同一个客户只算一个人头。 + * 如若A给客户X下订单,并给客户X服务,对A来说只算一个人头 + */ + private void achieveNumOfPeople(Set<Long> beautyIds, Long vipId) { + for (Long userId : beautyIds) { + double num; + List<AchieveNew> achieveNewList = achieveNewDao.selectBeautyManAchieveList(userId, vipId, new Date()); + + if (CollUtil.isEmpty(achieveNewList)) { + num = 1D; + } else { + num = 1D / achieveNewList.size(); + } + + achieveNewDao.updateAchieveNumOfPeople(achieveNewList, num); + } + + } + @Override public void addAchaeveByOrder(SysOrder pageOrder) { List<AchieveNew> achieveNewList = new ArrayList<>(); + Set<Long> beautyIds = new HashSet<>(); if (CollectionUtils.isNotEmpty(pageOrder.getItems())) { for (SysOrderItem orderItem : pageOrder.getItems()) { @@ -309,13 +333,19 @@ if (achieveNew !=null && achieveNew.getGoodsCash()!=null) { buildAchieve(pageOrder, orderItem, achieveNew); achieveNewList.add(achieveNew); + + beautyIds.add(achieveNew.getBeaultId()); } } } } } + if (CollectionUtils.isNotEmpty(achieveNewList)) { achieveNewDao.batchInsert(achieveNewList); + if (!beautyIds.isEmpty()) { + achieveNumOfPeople(beautyIds, pageOrder.getVipId()); + } } } @@ -354,7 +384,7 @@ } // 设置顾问人头业绩 - saleAchieveNumOfPeople(achieveNew); +// saleAchieveNumOfPeople(achieveNew); achieveNew.setOrderType(Dictionary.ORDER_TYPE_SEAL); achieveNew.setOrderId(pageOrder.getId()); 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 f569ace..f9bc208 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 @@ -1853,4 +1853,9 @@ sysInstoreInfoService.check(instoreInfo); } + + @Override + public BigDecimal findVipArrearsByVipId(Long vipId) { + return sysOrderDao.selectArrearsByVipId(vipId); + } } diff --git a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysVipInfoServiceImpl.java b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysVipInfoServiceImpl.java index 8980936..359169f 100644 --- a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysVipInfoServiceImpl.java +++ b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysVipInfoServiceImpl.java @@ -79,6 +79,9 @@ @Autowired ScoreVipDetailService scoreVipDetailService; + @Autowired + private SysOrderDao sysOrderDao; + /** * 新增会员储值卡 @@ -440,7 +443,9 @@ @Override public com.matrix.system.app.vo.VipInfoVo findApiVipInfoById(Long id) { - return sysVipInfoDao.selectVipInfoById(id); + com.matrix.system.app.vo.VipInfoVo result = sysVipInfoDao.selectVipInfoById(id); + result.setArrears(sysOrderDao.selectArrearsByVipId(id)); + return result; } @Override diff --git a/zq-erp/src/main/resources/config/application.properties b/zq-erp/src/main/resources/config/application.properties index 7b6d3b6..a110e8a 100644 --- a/zq-erp/src/main/resources/config/application.properties +++ b/zq-erp/src/main/resources/config/application.properties @@ -4,9 +4,13 @@ #线上测试环境 # +#spring.datasource.username=ct_test +#spring.datasource.password=123456 +#spring.datasource.url=jdbc:mysql://120.27.238.55:3306/hive_test_meidu?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true&transformedBitIsBoolean=true&serverTimezone=GMT%2B8 + spring.datasource.username=ct_test spring.datasource.password=123456 -spring.datasource.url=jdbc:mysql://120.27.238.55:3306/hive_test_meidu?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true&transformedBitIsBoolean=true&serverTimezone=GMT%2B8 +spring.datasource.url=jdbc:mysql://120.27.238.55:3306/hive_test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true&transformedBitIsBoolean=true&serverTimezone=GMT%2B8 #spring.datasource.username=xc_shop #spring.datasource.password=xc_shop123!@# diff --git a/zq-erp/src/main/resources/mybatis/mapper/hive/SysOrderDao.xml b/zq-erp/src/main/resources/mybatis/mapper/hive/SysOrderDao.xml index a9ba0be..955e108 100644 --- a/zq-erp/src/main/resources/mybatis/mapper/hive/SysOrderDao.xml +++ b/zq-erp/src/main/resources/mybatis/mapper/hive/SysOrderDao.xml @@ -494,7 +494,7 @@ MAX(pay_time) payTime, GROUP_CONCAT(DISTINCT t2.shop_short_name) shopName from sys_order t1 - left join sys_order_flow b on t1.id=b.ORDER_ID and pay_method!='储值卡' + left join sys_order_flow b on t1.id=b.ORDER_ID and pay_method!='储值卡' and pay_method!='欠款' left join sys_shop_info t2 on t1.SHOP_ID=t2.ID where t1.VIP_ID=#{vipId} and STATU='已付款'; </select> @@ -690,4 +690,8 @@ </select> + <select id="selectArrearsByVipId" resultType="java.math.BigDecimal"> + select sum(arrears) from sys_order + where vip_id=#{vipId} and statu='欠款' + </select> </mapper> \ No newline at end of file diff --git a/zq-erp/src/main/resources/templates/views/admin/hive/beautySalon/vip.html b/zq-erp/src/main/resources/templates/views/admin/hive/beautySalon/vip.html index c2b4cda..654e4b9 100644 --- a/zq-erp/src/main/resources/templates/views/admin/hive/beautySalon/vip.html +++ b/zq-erp/src/main/resources/templates/views/admin/hive/beautySalon/vip.html @@ -150,6 +150,7 @@ <el-row style="padding: 10px 20px;"> <p>余额:<span v-if="vipInfo.balance != null">{{vipInfo.balance}}元</span></p> <p>积分:<span v-if="vipInfo.pointAll != null">{{vipInfo.pointAll}}</span></p> + <p>欠款金额:<span v-if="vipInfo.arrears != null">{{vipInfo.arrears}} 元</span></p> <p>累计消费金额:<span v-if="vipInfo.totalMoney != null">{{vipInfo.totalMoney.toFixed(2)}} 元</span></p> <p>累计消费次数:<span v-if="vipInfo.totalTimes != null">{{vipInfo.totalTimes}} 次</span></p> <p>上次消费时间:<span v-if="vipInfo.payTime">{{vipInfo.payTime}}</span></p> -- Gitblit v1.9.1