zq-erp/pom.xml
@@ -393,6 +393,11 @@ <artifactId>hutool-all</artifactId> <version>5.3.1</version> </dependency> <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>26.0-jre</version> </dependency> </dependencies> <build> <resources> zq-erp/src/main/java/com/matrix/core/tools/SmsUtils.java
@@ -1,5 +1,6 @@ package com.matrix.core.tools; import cn.hutool.json.JSONUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.aliyuncs.CommonRequest; @@ -7,7 +8,6 @@ import com.aliyuncs.IAcsClient; import com.aliyuncs.exceptions.ClientException; import com.aliyuncs.http.MethodType; import com.google.gson.JsonObject; import com.matrix.config.properties.AliSmsProperties; import com.matrix.core.exception.GlobleException; import com.matrix.system.hive.bean.SysSmsTemplate; @@ -15,7 +15,6 @@ import org.springframework.stereotype.Component; import javax.annotation.Resource; import java.util.HashMap; import java.util.Map; /** @@ -57,8 +56,7 @@ CommonRequest request = commonRequest(SysSmsTemplate.SMS_ACTION_SEND); request.putQueryParameter("PhoneNumbers", phoneNum); request.putQueryParameter("TemplateCode", templateCode); String jsonStr = JSONObject.toJSONString(values); request.putQueryParameter("TemplateParam", jsonStr); request.putQueryParameter("TemplateParam", JSONUtil.parse(values).toString()); CommonResponse response = null; try { zq-erp/src/main/java/com/matrix/system/app/action/ApiServiceOrderAction.java
@@ -282,17 +282,8 @@ @ApiOperation(value = "确认服务", notes = "确认服务") @PostMapping(value = "/confirmServiceOrder") public AjaxResult confirmServiceOrder(@RequestBody @Validated IdSubmitDto idSubmitDto) { SysProjServices services = new SysProjServices(); services.setId(idSubmitDto.getId()); services.setState(Dictionary.BEATUI_STATE_DYY); int i = projServicesService.modify(services); int i=projServicesService.confirmServiceOrder(idSubmitDto.getId()); if (i > 0) { //发送微信公众号提醒 services=projServicesService.findById(services.getId()); UniformMsgParam uniformMsgParam=new UniformMsgParam(services.getCompanyId(),UniformMsgParam.GZH_YYCG); uniformMsgParam.put("serviceId",services.getId()); asyncMessageManager.sendMsg(AsyncMessageRouting.SEND_UNIFORM_TEMPLATE_MSG ,uniformMsgParam); return AjaxResult.buildSuccessInstance("确认成功"); } return AjaxResult.buildFailInstance("确认失败"); zq-erp/src/main/java/com/matrix/system/common/constance/AppConstance.java
@@ -582,6 +582,14 @@ * 门店是否只能取消待付款订单,服务单 */ public static final String SHOP_MANAGE_ABLE_CANCEL_DFK_ORDER = "shopManageAbleCancelDfkOrder"; /** * 服务记录跟进模板 */ public static final String SERVICE_FLOW_TEMPLATE = "SERVICE_FLOW_TEMPLATE"; /** * 开启短信提醒 */ public static final String OPEN_SMS_NOTICE = "OPEN_SMS_NOTICE"; /** * 赠送金额购买产品算赠送购买 zq-erp/src/main/java/com/matrix/system/hive/action/ProjServiceController.java
@@ -14,6 +14,7 @@ import com.matrix.core.tools.excl.ExcelSheetPO; import com.matrix.core.tools.excl.ExcelUtil; import com.matrix.core.tools.excl.ExcelVersion; import com.matrix.system.app.dto.IdSubmitDto; import com.matrix.system.common.bean.BusParameterSettings; import com.matrix.system.common.bean.SysUsers; import com.matrix.system.common.constance.AppConstance; @@ -26,10 +27,13 @@ import com.matrix.system.hive.bean.*; import com.matrix.system.hive.dao.*; import com.matrix.system.hive.service.*; import io.swagger.annotations.ApiOperation; import org.apache.commons.collections.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; @@ -390,6 +394,17 @@ } } @ApiOperation(value = "确认服务", notes = "确认服务") @PostMapping(value = "/confirmServiceOrder") public @ResponseBody AjaxResult confirmServiceOrder(Long id) { int i=sysProjServicesService.confirmServiceOrder(id); if(i>0){ return AjaxResult.buildSuccessInstance("确认成功"); } return AjaxResult.buildFailInstance("确认失败"); } /** * @author jiangyouyao zq-erp/src/main/java/com/matrix/system/hive/service/SysProjServicesService.java
@@ -113,4 +113,11 @@ int findApiServiceOrderListTotal(ServiceOrderListDto serviceOrderListDto); public boolean skipServiceOrderStep(String step); /** * 确认服务单 * @param id * @return */ int confirmServiceOrder(Long id); } zq-erp/src/main/java/com/matrix/system/hive/service/TaiYanAliyunSmsService.java
New file @@ -0,0 +1,140 @@ /** * projectName: zq-erp * fileName: TaiYanAliyunSmsService.java * packageName: com.matrix.system.hive.service * date: 2021-10-28 11:18 * copyright(c) 2021 http://www.hydee.cn/ Inc. All rights reserved. */ package com.matrix.system.hive.service; import com.google.common.collect.Maps; import com.matrix.core.tools.DateUtil; import com.matrix.core.tools.LogUtil; import com.matrix.core.tools.SmsUtils; import com.matrix.core.tools.StringUtils; import com.matrix.system.common.bean.BusParameterSettings; import com.matrix.system.common.constance.AppConstance; import com.matrix.system.common.dao.BusParameterSettingsDao; import com.matrix.system.hive.bean.SysBeauticianState; import com.matrix.system.hive.bean.SysProjServices; import com.matrix.system.hive.bean.SysShopInfo; import com.matrix.system.hive.bean.SysVipInfo; import com.matrix.system.hive.dao.SysVipInfoDao; import lombok.AllArgsConstructor; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import java.util.Date; import java.util.HashMap; import java.util.List; /** * @version: V1.0 * @author: JiangYouYao * @className: TaiYanAliyunSmsService * @packageName: com.matrix.system.hive.service * @description: 肽妍短信提醒服务 * @data: 2021-10-28 11:18 **/ @Service @AllArgsConstructor public class TaiYanAliyunSmsService { SysVipInfoDao vipInfoDao; SmsUtils smsUtils; SysShopInfoService shopInfoService; SysBeauticianStateService sysBeauticianStateService; BusParameterSettingsDao busParameterSettingsDao; /** * 预约成功短信提醒 * * @param services */ @Async public void sendYycgNotice(SysProjServices services) { //短信接口为肽妍公司定制,暂时写死 if (services.getCompanyId() != 17L) { return; } if (isCloseSmsNotice(services)){ return; } SysVipInfo sysVipInfo = vipInfoDao.selectById(services.getVipId()); SysShopInfo shopInfo = shopInfoService.findById(services.getShopId()); String date = DateUtil.dateFormatStr(new Date(), "yyyy年MM月dd日"); LogUtil.debug("发送阿里云预约成功短信,手机号={}", sysVipInfo.getPhone()); if (StringUtils.isNotBlank(sysVipInfo.getPhone())) { HashMap<String, String> param = Maps.newHashMap(); param.put("date", date); param.put("tel", shopInfo.getShopTel()); param.put("shopName", shopInfo.getShopName()); smsUtils.sendSms(sysVipInfo.getPhone(), "SMS_226995798", param); } } /** * 判断是否开启了短信提醒 * @param services * @return */ private boolean isCloseSmsNotice(SysProjServices services) { BusParameterSettings openSmsNoticeSetting = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.OPEN_SMS_NOTICE, services.getCompanyId()); if (StringUtils.isBlank(openSmsNoticeSetting.getParamValue()) || AppConstance.IS_N.equals(openSmsNoticeSetting.getParamValue())) { LogUtil.debug("未开启短信提醒"); return true; } return false; } /** * 项目划扣短信提醒 * * @param services */ @Async public void sendHkNotice(SysProjServices services) { //短信接口为肽妍公司定制,暂时写死 if (services.getCompanyId() != 17L) { return; } if (isCloseSmsNotice(services)){ return; } SysVipInfo sysVipInfo = vipInfoDao.selectById(services.getVipId()); SysShopInfo shopInfo = shopInfoService.findById(services.getShopId()); String date = DateUtil.dateFormatStr(new Date(), "yyyy年MM月dd日"); List<SysBeauticianState> items = sysBeauticianStateService.findBySerId(services.getId()); for (SysBeauticianState item : items) { if (item.getProjInfo() != null) { String projName = item.getProjInfo().getName(); LogUtil.debug("发送阿里云项目划扣短信,手机号={}", sysVipInfo.getPhone()); if (StringUtils.isNotBlank(sysVipInfo.getPhone())) { HashMap<String, String> param = Maps.newHashMap(); param.put("date", date); param.put("projName", projName); param.put("count", item.getCount() + ""); param.put("balanceCount", item.getProjUse().getSurplusCount() + ""); param.put("tel", shopInfo.getShopTel()); param.put("shopName", shopInfo.getShopName()); smsUtils.sendSms(sysVipInfo.getPhone(), "SMS_226995796", param); } } } } } zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java
@@ -36,7 +36,6 @@ import com.matrix.system.wechart.templateMsg.UniformMsgParam; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -483,9 +482,7 @@ // 更新收款时间 pageOrder.setPayTime(new Date()); pageOrder.setStatu(Dictionary.ORDER_STATU_YFK); sysOrderDao.update(pageOrder); updateOrderInfo(pageOrder); // 获取用户信息 SysVipInfo vipInfo = sysVipInfoDao.selectById(pageOrder.getVipId()); @@ -515,6 +512,30 @@ //设置会员积分 addVipScore(pageOrder); } /** * 付款后更新订单信息 * @param pageOrder */ private void updateOrderInfo(SysOrder pageOrder) { pageOrder.setPayTime(new Date()); pageOrder.setStatu(Dictionary.ORDER_STATU_YFK); List<SysOrderFlow> flows = pageOrder.getFlows(); BigDecimal cashPayAmount = flows.stream() .filter(item -> (!item.getPayMethod().equals("储值卡")) && (!item.getPayMethod().equals("欠款"))) .map(SysOrderFlow::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal cardPayAmount = flows.stream() .filter(item -> item.getPayMethod().equals("储值卡") && item.getIsGift().equals("N")) .map(SysOrderFlow::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add); pageOrder.setCardPay(cardPayAmount.doubleValue()); pageOrder.setCashPay(cashPayAmount.doubleValue()); //欠款金额在流水处理中处理了 sysOrderDao.update(pageOrder); } private void checkOrder(SysOrder pageOrder) { @@ -1380,17 +1401,20 @@ //赠送项目是否计算消耗业绩否则 赠送产品按原价计算消耗 boolean zsConsumeAchieve = projServicesService.skipServiceOrderStep(Dictionary.ZS_CONSUME_ACHIEVE); if (zsConsumeAchieve) { //赠送情况下,如果收款金额大于0,就是赠送金额划扣的情况,金额即为划扣的折扣金额 if(sysOrderItem.getZkPrice()>0){ puse.setPrice(sysOrderItem.getZkPrice()); }else{ puse.setPrice(sysOrderItem.getShoppingGoods().getSealPice()); } } else { puse.setPrice(0D); } } // 设置失效时间 Date invalidTime = shoppingGoodsService.calInvalidTime(sysOrderItem.getShoppingGoods(), 1, null); puse.setFailTime(invalidTime); puse.setBalance(sysOrderItem.getShoppingGoods().getSealPice() * puse.getSurplusCount()); puse.setBalance(puse.getPrice() * puse.getSurplusCount()); sysProjUseDao.insert(puse); } zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysProjServicesServiceImpl.java
@@ -6,10 +6,7 @@ import com.matrix.core.exception.GlobleException; import com.matrix.core.pojo.PaginationVO; import com.matrix.core.pojo.VerifyResult; import com.matrix.core.tools.DateUtil; import com.matrix.core.tools.LogUtil; import com.matrix.core.tools.StringUtils; import com.matrix.core.tools.WebUtil; import com.matrix.core.tools.*; import com.matrix.system.app.dto.ServiceOrderListDto; import com.matrix.system.app.vo.ServiceOrderListVo; import com.matrix.system.common.bean.BusParameterSettings; @@ -67,7 +64,8 @@ private SysOutStoreItemDao sysOutStoreItemDao; @Autowired private SysBedInfoDao sysBedInfoDao; @Autowired TaiYanAliyunSmsService taiYanAliyunSmsService; @Autowired private SysStoreInfoDao storeInfoDao; @@ -663,6 +661,8 @@ UniformMsgParam uniformMsgParam = new UniformMsgParam(projServices.getCompanyId(), UniformMsgParam.GZH_FWWC); uniformMsgParam.put("serviceId", projServices.getId()); asyncMessageManager.sendMsg(AsyncMessageRouting.SEND_UNIFORM_TEMPLATE_MSG ,uniformMsgParam); //发送划扣短信提醒 taiYanAliyunSmsService.sendHkNotice(projServices); return result; } @@ -1052,4 +1052,31 @@ return flag; } @Override public int confirmServiceOrder(Long id) { SysProjServices services = new SysProjServices(); services.setId(id); services.setState(Dictionary.BEATUI_STATE_DYY); int i = modify(services); if (i > 0) { //发送微信公众号提醒 services=findById(services.getId()); UniformMsgParam uniformMsgParam=new UniformMsgParam(services.getCompanyId(),UniformMsgParam.GZH_YYCG); uniformMsgParam.put("serviceId",services.getId()); asyncMessageManager.sendMsg(AsyncMessageRouting.SEND_UNIFORM_TEMPLATE_MSG ,uniformMsgParam); taiYanAliyunSmsService.sendYycgNotice(services); } return i; } } zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/Task/UniformMsgSentTask.java
@@ -55,14 +55,13 @@ public void handle(Map<String,Object> param){ try { JSONObject messageJsonParam=JSONObject.parseObject(param.get("messages").toString()); if(!messageJsonParam.containsKey("companyId")||(!messageJsonParam.containsKey("templateCode"))){ if(!param.containsKey("companyId")||(!param.containsKey("templateCode"))){ LogUtil.error("小程序消息推送参数格式异常发送模板消息需要传JSONO字符串作为格式 例如:{\"companyId\":17,\"templateCode\":10000} companyId 、templateCode 是必须属性"); return; } Long companyId = Long.parseLong( messageJsonParam.get("companyId").toString()); Integer templateCode = Integer.parseInt( messageJsonParam.get("templateCode").toString()); Long companyId = Long.parseLong( param.get("companyId").toString()); Integer templateCode = Integer.parseInt( param.get("templateCode").toString()); //获取公司微信配置参数 BusParameterSettings xcxAppId = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.MINIPROGRAM_APPID, companyId); @@ -82,7 +81,7 @@ bulderParam.put("xcxAppId", xcxAppId.getParamValue()); bulderParam.put("gzhAppid", gzhAppid.getParamValue()); bulderParam.put("template_id", template.getUuid()); bulderParam.put("messageJsonParam", messageJsonParam); bulderParam.put("messageJsonParam", param); //调用模板计算出消息体 Map msgResult = templateMessageBulder.buildMsg(bulderParam); zq-erp/src/main/resources/config/application.properties
@@ -4,9 +4,9 @@ #线上测试环境 # 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.username=xc_shop #spring.datasource.password=xc_shop123!@# @@ -22,9 +22,9 @@ #spring.datasource.url=jdbc:mysql://47.111.134.136/db_meidu_prd?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true&transformedBitIsBoolean=true&serverTimezone=GMT%2B8 #spring.datasource.username=root #spring.datasource.password=root #spring.datasource.url=jdbc:mysql://127.0.0.1:3306/md_test_local?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true&transformedBitIsBoolean=true&serverTimezone=GMT%2B8 spring.datasource.username=root spring.datasource.password=root spring.datasource.url=jdbc:mysql://127.0.0.1:3306/md_test_local?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true&transformedBitIsBoolean=true&serverTimezone=GMT%2B8 spring.datasource.type=com.alibaba.druid.pool.DruidDataSource zq-erp/src/main/resources/templates/views/admin/hive/beautySalon/service_all_list.html
@@ -202,6 +202,9 @@ html +=btns[4].replace('VALUE',value); html += btns[2].replace('VALUE',value); break; case '待确认': html +=btns[7].replace('VALUE',value); break; } html += btns[5].replace('VALUE',value); html += btns[6].replace('VALUE',value); @@ -290,6 +293,24 @@ } function confirmServiceOrder(id) { layer.confirm('确定确认订单吗?', { btn: ['确认', '取消'] //可以无限个按钮 }, function(index, layero){ $.post(basePath+'/admin/projService/confirmServiceOrder?id='+id, {}, function(data){ parent.layer.msg(data.info,{icon: 1}); layer.closeAll(); myGrid.serchData(); }); //按钮【按钮一】的回调 }, function(index){ // alert("2 = "+index); //按钮【按钮二】的回调 }); } //打开查看界面 function openEdit2() { var id=myGrid.getSelectItemId(); @@ -337,5 +358,8 @@ <script matrix:btn="serviceClub-edit"> btns[6]='<a class="text-primary mr-5" onclick="updateTime(\'VALUE\')" title="修改时间"><i class="fa fa-edit">修改时间</i></a> ' </script> <script matrix:btn="serviceClub-edit"> btns[7]='<a class="text-primary mr-5" onclick="confirmServiceOrder(\'VALUE\')" title="确认服务单"><i class="fa fa-edit">确认服务单</i></a> ' </script> </html> zq-erp/src/main/resources/templates/views/admin/shop/parameterSetting-form.html
@@ -71,6 +71,14 @@ </el-checkbox-group> </div> </div> <div class="form-group" v-if="paramSetting.type==5"> <label class="col-md-2 control-label">{{paramSetting.name}}</label> <div class="col-md-8"> <el-input type="textarea" :rows="2" v-model="paramSetting.userValue"></el-input> </div> </div> </template> zq-erp/src/test/java/com/matrix/ParameterSettingsTool.java
@@ -105,6 +105,19 @@ newSetting8.setCategory("店务配置"); newSettings.add(newSetting8); ParameterSettings newSetting9=new ParameterSettings(); newSetting9.setCode(AppConstance.SERVICE_FLOW_TEMPLATE); newSetting9.setName("跟进记录模板"); newSetting9.setType(5); newSetting9.setCategory("店务配置"); newSettings.add(newSetting9); ParameterSettings newSetting10=new ParameterSettings(); newSetting10.setCode(AppConstance.OPEN_SMS_NOTICE); newSetting10.setName("是否开启短信提醒"); newSetting10.setType(1); newSetting10.setCategory("店务配置"); newSettings.add(newSetting10); for (ParameterSettings newSetting : newSettings) { List<ParameterSettings> parameterSettings = parameterSettingsDao.selectByModel(newSetting); zq-erp/src/test/java/com/matrix/TaiYanAliyunSmsServiceTest.java
New file @@ -0,0 +1,39 @@ package com.matrix; import com.matrix.system.hive.bean.SysProjServices; import com.matrix.system.hive.service.SysProjServicesService; import com.matrix.system.hive.service.TaiYanAliyunSmsService; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; /** * @author jiangyouyao * @email 512061637@qq.com * @date 2019年2月25日 */ @RunWith(SpringRunner.class) @SpringBootTest(classes = {ZqErpApplication.class},webEnvironment =SpringBootTest.WebEnvironment.RANDOM_PORT) public class TaiYanAliyunSmsServiceTest { @Autowired private TaiYanAliyunSmsService taiYanAliyunSmsService; @Autowired SysProjServicesService projServicesService; @Test public void addSendYycgNotice(){ SysProjServices byId = projServicesService.findById(215550L); byId.setVipId(5949L); taiYanAliyunSmsService.sendYycgNotice(byId); taiYanAliyunSmsService.sendHkNotice(byId); } }