| | |
| | | import com.doumee.dao.business.model.Orders; |
| | | import com.doumee.dao.business.model.PricingRule; |
| | | import com.doumee.dao.business.model.ShopInfo; |
| | | import com.doumee.config.xyy.XyyConfig; |
| | | import com.doumee.config.xyy.dto.AddPrinterRequest; |
| | | import com.doumee.config.xyy.dto.AddPrinterRequestItem; |
| | | import com.doumee.config.xyy.dto.DelPrinterRequest; |
| | | import com.doumee.config.xyy.vo.ObjectRestResponse; |
| | | import com.doumee.config.xyy.vo.PrinterResult; |
| | | import com.doumee.dao.dto.*; |
| | | import com.doumee.dao.system.model.SystemDictData; |
| | | import com.doumee.dao.system.SystemUserMapper; |
| | |
| | | |
| | | @Autowired |
| | | private SmsrecordMapper smsrecordMapper; |
| | | |
| | | @Autowired |
| | | private PrintService printService; |
| | | |
| | | @Autowired |
| | | private XyyConfig xyyConfig; |
| | | @Override |
| | | public Integer create(ShopInfo shopInfo) { |
| | | shopInfoMapper.insert(shopInfo); |
| | |
| | | if (pageWrap.getModel().getOpenid() != null) { |
| | | queryWrapper.lambda().like(ShopInfo::getOpenid, pageWrap.getModel().getOpenid()); |
| | | } |
| | | for (PageWrap.SortData sortData : pageWrap.getSorts()) { |
| | | if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { |
| | | queryWrapper.orderByDesc(sortData.getProperty()); |
| | | } else { |
| | | queryWrapper.orderByAsc(sortData.getProperty()); |
| | | } |
| | | } |
| | | queryWrapper.lambda().orderByDesc(ShopInfo::getId); |
| | | return PageData.from(shopInfoMapper.selectPage(page, queryWrapper)); |
| | | } |
| | | |
| | |
| | | vo.setFeeStandard(shop.getFeeStandard()); |
| | | vo.setLatitude(shop.getLatitude()); |
| | | vo.setLongitude(shop.getLongitude()); |
| | | vo.setLinkPhone(shop.getLinkPhone()); |
| | | |
| | | // 门头照 + 内部照 全路径集合 |
| | | String imgPrefix = getShopPrefix(); |
| | |
| | | // 存件门店 |
| | | List<Orders> depositSalesOrders = ordersMapper.selectList(new QueryWrapper<Orders>().lambda() |
| | | .eq(Orders::getDeleted, Constants.ZERO) |
| | | .notIn(Orders::getStatus,Constants.OrderStatus.cancelled.getStatus(),Constants.OrderStatus.waitPay.getStatus()) |
| | | .ge(Orders::getCreateTime, startTime) |
| | | .lt(Orders::getCreateTime, endTime) |
| | | .eq(Orders::getDepositShopId, shopId)); |
| | | // 取件门店 |
| | | List<Orders> takeSalesOrders = ordersMapper.selectList(new QueryWrapper<Orders>().lambda() |
| | | .eq(Orders::getDeleted, Constants.ZERO) |
| | | .eq(Orders::getType,Constants.ONE) |
| | | .notIn(Orders::getStatus,Constants.OrderStatus.cancelled.getStatus(),Constants.OrderStatus.waitPay.getStatus()) |
| | | .ge(Orders::getCreateTime, startTime) |
| | | .lt(Orders::getCreateTime, endTime) |
| | | .eq(Orders::getTakeShopId, shopId)); |
| | |
| | | vo.setSettlementProfit(depositFee + takeFee); |
| | | |
| | | // 3. 在库订单数 |
| | | // 3.1 存件门店=本门店,status in (2已寄存, 5待取件) |
| | | Long depositStorageCount = ordersMapper.selectCount(new QueryWrapper<Orders>().lambda() |
| | | // 3.1 就地订单:存件门店=本门店,type=0,status in (2已寄存, 5待取件) |
| | | Long localStorageCount = ordersMapper.selectCount(new QueryWrapper<Orders>().lambda() |
| | | .eq(Orders::getDeleted, Constants.ZERO) |
| | | .eq(Orders::getDepositShopId, shopId) |
| | | .eq(Orders::getType, Constants.ZERO) |
| | | .in(Orders::getStatus, |
| | | Constants.OrderStatus.deposited.getStatus(), |
| | | Constants.OrderStatus.arrived.getStatus())); |
| | | // 3.2 取件门店=本门店,status = 5待取件 |
| | | // 3.2 异地订单:存件门店=本门店,type=1,status=2已寄存 |
| | | Long remoteStorageCount = ordersMapper.selectCount(new QueryWrapper<Orders>().lambda() |
| | | .eq(Orders::getDeleted, Constants.ZERO) |
| | | .eq(Orders::getDepositShopId, shopId) |
| | | .eq(Orders::getType, Constants.ONE) |
| | | .eq(Orders::getStatus, Constants.OrderStatus.deposited.getStatus())); |
| | | // 3.3 取件门店=本门店,异地订单,status = 5待取件 |
| | | Long takeStorageCount = ordersMapper.selectCount(new QueryWrapper<Orders>().lambda() |
| | | .eq(Orders::getDeleted, Constants.ZERO) |
| | | .eq(Orders::getType,Constants.ONE) |
| | | .eq(Orders::getTakeShopId, shopId) |
| | | .eq(Orders::getStatus, Constants.OrderStatus.arrived.getStatus())); |
| | | vo.setStorageCount(depositStorageCount.intValue() + takeStorageCount.intValue()); |
| | | vo.setStorageCount(localStorageCount.intValue() + remoteStorageCount.intValue() + takeStorageCount.intValue()); |
| | | |
| | | return vo; |
| | | } |
| | |
| | | .last("limit 1") |
| | | ); |
| | | if(shop==null){ |
| | | throw new BusinessException(ResponseStatus.ACCOUNT_INCORRECT); |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"请核对登录手机号是否正确"); |
| | | } |
| | | if(Constants.equalsInteger(shop.getStatus(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"门店已禁用,请联系管理员"); |
| | | } |
| | | if(!Constants.equalsInteger(shop.getAuditStatus(),Constants.THREE)){ |
| | | if(Constants.equalsInteger(shop.getAuditStatus(),Constants.ONE)){ |
| | |
| | | .last("limit 1")); |
| | | if (shop == null) { |
| | | return null; |
| | | } |
| | | if(Constants.equalsInteger(shop.getStatus(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"门店已禁用,请联系管理员"); |
| | | } |
| | | // 创建token(generateTokenForRedis 已自动清除该用户旧token,保证唯一有效) |
| | | String token = JwtTokenUtil.generateTokenForRedis(shop.getId(), Constants.TWO, JSONObject.toJSONString(shop), redisTemplate); |
| | |
| | | if (shopInfo.getCompanyType() == null) { |
| | | return; |
| | | } |
| | | Areas areas = areasService.findById(shopInfo.getAreaId()); |
| | | PricingRule pricingRule = pricingRuleMapper.selectOne(new QueryWrapper<PricingRule>().lambda() |
| | | .eq(PricingRule::getDeleted, Constants.ZERO) |
| | | .eq(PricingRule::getType, Constants.THREE) |
| | | .eq(PricingRule::getFieldA, String.valueOf(shopInfo.getCompanyType())) |
| | | .eq(PricingRule::getFieldA, String.valueOf(Constants.equalsInteger(shopInfo.getCompanyType(),Constants.ZERO)?Constants.ONE:Constants.ZERO)) |
| | | .eq(PricingRule::getCityId, areas.getParentId()) |
| | | .last("limit 1")); |
| | | if (pricingRule != null && StringUtils.isNotBlank(pricingRule.getFieldB())) { |
| | | shopInfo.setDepositAmount(Long.parseLong(pricingRule.getFieldB())); |
| | |
| | | for (int i = 0; i < paramPairs.length - 1; i += 2) { |
| | | templateParam.put(paramPairs[i], paramPairs[i + 1]); |
| | | } |
| | | boolean result = AliSmsService.sendSms(phone, smsNotify.getTemplateCode(), |
| | | String error = AliSmsService.sendSms(phone, smsNotify.getTemplateCode(), |
| | | templateParam.toJSONString()); |
| | | if (result) { |
| | | log.info("短信发送成功: phone={}, template={}", phone, smsNotify.name()); |
| | | } else { |
| | | log.warn("短信发送失败: phone={}, template={}", phone, smsNotify.name()); |
| | | } |
| | | // 存储短信记录 |
| | | Smsrecord smsRecord = new Smsrecord(); |
| | | smsRecord.setPhone(phone); |
| | | smsRecord.setContent(content); |
| | | smsRecord.setType(Constants.ONE); |
| | | smsRecord.setStatus(result ? Constants.ONE : Constants.ZERO); |
| | | smsRecord.setStatus(error == null ? Constants.ONE : Constants.ZERO); |
| | | if (error != null) { |
| | | smsRecord.setRemark(error); |
| | | } |
| | | smsRecord.setCreateTime(new Date()); |
| | | smsRecord.setDeleted(Constants.ZERO); |
| | | smsrecordMapper.insert(smsRecord); |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void maintainPrinterSn(ShopPrinterDTO dto) { |
| | | ShopInfo shop = shopInfoMapper.selectById(dto.getId()); |
| | | if (shop == null || Constants.equalsInteger(shop.getDeleted(), Constants.ONE)) { |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | String oldSn = shop.getPrinterSn(); |
| | | String newSn = dto.getPrinterSn(); |
| | | boolean hasNewSn = StringUtils.isNotBlank(newSn); |
| | | boolean hasOldSn = StringUtils.isNotBlank(oldSn); |
| | | |
| | | if (!hasNewSn) { |
| | | // 未传打印机SN → 删除逻辑 |
| | | if (hasOldSn) { |
| | | delPrinterFromXyy(oldSn); |
| | | shop.setPrinterSn(null); |
| | | shopInfoMapper.updateById(shop); |
| | | } |
| | | return; |
| | | } |
| | | |
| | | // 传了打印机SN → 如果旧绑定存在,先删除 |
| | | if (hasOldSn) { |
| | | delPrinterFromXyy(oldSn); |
| | | } |
| | | |
| | | // 绑定新打印机 |
| | | AddPrinterRequest addReq = new AddPrinterRequest(); |
| | | xyyConfig.createRequestHeader(addReq); |
| | | addReq.setItems(new AddPrinterRequestItem[]{new AddPrinterRequestItem() {{ |
| | | setSn(newSn); |
| | | setName(shop.getName()); |
| | | }}}); |
| | | ObjectRestResponse<PrinterResult> addResp = printService.addPrinters(addReq); |
| | | if (addResp.getCode() != 0) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "绑定打印机失败:" + addResp.getMsg()); |
| | | } |
| | | log.info("绑定成功:{}", newSn); |
| | | shop.setPrinterSn(newSn); |
| | | shopInfoMapper.updateById(shop); |
| | | } |
| | | |
| | | private void delPrinterFromXyy(String sn) { |
| | | DelPrinterRequest delReq = new DelPrinterRequest(); |
| | | xyyConfig.createRequestHeader(delReq); |
| | | delReq.setSnlist(new String[]{sn}); |
| | | ObjectRestResponse<PrinterResult> delResp = printService.delPrinters(delReq); |
| | | if (delResp.getCode() != 0) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "解绑打印机失败:" + delResp.getMsg()); |
| | | } |
| | | log.info("解绑成功:{}", sn); |
| | | } |
| | | |
| | | } |