diff --git a/.gitignore b/.gitignore index f173b81..7a0e47b 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,5 @@ build/ ### VS Code ### .vscode/ +nxhs-service/src/main/resources/application.yml +*.yml diff --git a/nxhs-common/src/main/java/cc/yunxi/common/domain/CommonResult.java b/nxhs-common/src/main/java/cc/yunxi/common/domain/CommonResult.java index dd02972..2feba10 100644 --- a/nxhs-common/src/main/java/cc/yunxi/common/domain/CommonResult.java +++ b/nxhs-common/src/main/java/cc/yunxi/common/domain/CommonResult.java @@ -36,6 +36,13 @@ public class CommonResult implements Serializable { result.msg = ""; return result; } + public static CommonResult success(T data, String message) { + CommonResult result = new CommonResult<>(); + result.code = 200; + result.data = data; + result.msg = message; + return result; + } public static boolean isSuccess(Integer code) { return Objects.equals(code, 200); diff --git a/nxhs-common/src/main/java/cc/yunxi/common/utils/CommonUtil.java b/nxhs-common/src/main/java/cc/yunxi/common/utils/CommonUtil.java index 9239333..8ef9aa8 100644 --- a/nxhs-common/src/main/java/cc/yunxi/common/utils/CommonUtil.java +++ b/nxhs-common/src/main/java/cc/yunxi/common/utils/CommonUtil.java @@ -162,6 +162,32 @@ public class CommonUtil { } }); } + public static String dateNow(String pattern) { + Date date = new Date(); + if (pattern == null && "".equals(pattern)) { + return null; + } else { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + String dateString = formatter.format(date); + return dateString; + } + } + + public static String padRight(String src, int len, char ch) { + int diff = len - src.length(); + if (diff <= 0) { + return src; + } else { + char[] charr = new char[len]; + System.arraycopy(src.toCharArray(), 0, charr, diff, src.length()); + + for(int i = 0; i < diff; ++i) { + charr[i] = ch; + } + + return new String(charr); + } + } public static void main(String[] args) { diff --git a/nxhs-service/src/main/java/cc/yunxi/config/RestTemplateConfig.java b/nxhs-service/src/main/java/cc/yunxi/config/RestTemplateConfig.java new file mode 100644 index 0000000..5dc7993 --- /dev/null +++ b/nxhs-service/src/main/java/cc/yunxi/config/RestTemplateConfig.java @@ -0,0 +1,23 @@ +package cc.yunxi.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.client.ClientHttpRequestFactory; +import org.springframework.http.client.SimpleClientHttpRequestFactory; +import org.springframework.web.client.RestTemplate; + +@Configuration +public class RestTemplateConfig { + @Bean + public RestTemplate restTemplate(ClientHttpRequestFactory factory){ + return new RestTemplate(factory); + } + + @Bean + public ClientHttpRequestFactory simpleClientHttpRequestFactory(){ + SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory(); + factory.setConnectTimeout(15000); + factory.setReadTimeout(5000); + return factory; + } +} diff --git a/nxhs-service/src/main/java/cc/yunxi/controller/EntranceController.java b/nxhs-service/src/main/java/cc/yunxi/controller/EntranceController.java new file mode 100644 index 0000000..d321ae3 --- /dev/null +++ b/nxhs-service/src/main/java/cc/yunxi/controller/EntranceController.java @@ -0,0 +1,58 @@ +package cc.yunxi.controller; + + +import cc.yunxi.aspect.UserTypeAnnotation; +import cc.yunxi.common.domain.CommonResult; +import cc.yunxi.common.domain.PageDTO; +import cc.yunxi.common.utils.BeanUtils; +import cc.yunxi.domain.dto.UserDTO; +import cc.yunxi.domain.dto.WxLoginDTO; +import cc.yunxi.domain.dto.ZSGLoginDTO; +import cc.yunxi.domain.po.Client; +import cc.yunxi.domain.po.ClientAccountDetail; +import cc.yunxi.domain.query.ClientAccountQuery; +import cc.yunxi.domain.query.ClientQuery; +import cc.yunxi.domain.vo.client.ClientAccountRespVO; +import cc.yunxi.domain.vo.client.ClientRespVO; +import cc.yunxi.domain.vo.client.ClientUpdateVO; +import cc.yunxi.enums.UserTypeEnum; +import cc.yunxi.service.IClientService; +import cc.yunxi.service.impl.CommonService; +import cc.yunxi.utils.UserContext; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpHeaders; +import org.springframework.web.bind.annotation.*; + +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + *

+ * 散户信息 前端控制器 + *

+ * + * @author ccongli + * @since 2024-02-28 06:08:09 + */ +@Api(tags = "小智登录接口") +@RestController +@RequiredArgsConstructor +@Slf4j +public class EntranceController { + + private final CommonService commonService; + + @ApiOperation("小智系统请求用户登录接口") + @RequestMapping("/login_name") + public CommonResult ZSG_Login(@RequestParam(name="loginName",required = true) String loginName) { + + ZSGLoginDTO zsgLoginDTO = commonService.loginByZSG(loginName); + return CommonResult.success(zsgLoginDTO,"请求成功"); + } + +} diff --git a/nxhs-service/src/main/java/cc/yunxi/domain/dto/ZSGLoginDTO.java b/nxhs-service/src/main/java/cc/yunxi/domain/dto/ZSGLoginDTO.java new file mode 100644 index 0000000..9dc2b27 --- /dev/null +++ b/nxhs-service/src/main/java/cc/yunxi/domain/dto/ZSGLoginDTO.java @@ -0,0 +1,76 @@ +package cc.yunxi.domain.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.models.auth.In; +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +@Data +@ApiModel(description = "小程序认证实体") +public class ZSGLoginDTO { + + @ApiModelProperty(value = "序号") + private Long id; + + @ApiModelProperty(value = "登陆名称") + private String loginName; + + @ApiModelProperty(value = "状态 0:正常 1:冻结 2:删除") + private Integer stat; + + @ApiModelProperty(value = "角色 2:设备管理员 4:清运员 9:普通用户") + private Integer role; + + @ApiModelProperty(value = "积分") + private Integer score; +// +// @ApiModelProperty(value = "loginType") +// @NotBlank(message = "登陆类型:1手机号登陆 2网络登陆(小程序) ") +// private String loginType; +// +// @ApiModelProperty(value = "devid") +// @NotBlank(message = "设备id 默认为1代表没有配置文件") +// private String devid; +// +// @ApiModelProperty(value = "clientId") +// @NotBlank(message = "小智客户端id") +// private String clientId; +// +// @ApiModelProperty(value = "clientType") +// @NotBlank(message = "小智客户端类型") +// private String clientType; +// +// @ApiModelProperty(value = "clientVersion") +// @NotBlank(message = "小智客户端版本") +// private String clientVersion; +// +// @ApiModelProperty(value = "appid") +// @NotBlank(message = "小程序id") +// private String appid; +// +// @ApiModelProperty(value = "devsn") +// @NotBlank(message = "设备编码") +// private String devsn; +// +// @ApiModelProperty(value = "devType") +// @NotBlank(message = "设备类型") +// private String devType; +// +// @ApiModelProperty(value = "test") +// @NotBlank(message = "测试模式 1为测试模式") +// private String test; +// +// @ApiModelProperty(value = "ltn") +// @NotBlank(message = "登陆类型描述 手机号登陆 网络登陆") +// private String ltn; +// +// @ApiModelProperty(value = "ac") +// @NotBlank(message = "ac版本1") +// private String ac; +// +// @ApiModelProperty(value = "acc") +// @NotBlank(message = "ac版本2") +// private String acc; +} diff --git a/nxhs-service/src/main/java/cc/yunxi/domain/po/BillRule.java b/nxhs-service/src/main/java/cc/yunxi/domain/po/BillRule.java new file mode 100644 index 0000000..8360124 --- /dev/null +++ b/nxhs-service/src/main/java/cc/yunxi/domain/po/BillRule.java @@ -0,0 +1,96 @@ +package cc.yunxi.domain.po; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.math.BigDecimal; + +/** + * 回收员表 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@TableName("base_bill_rule") +@ApiModel(value = "BillRule", description = "单据规则") +public class BillRule { + + @TableId(value = "f_id", type = IdType.ASSIGN_ID) + @ApiModelProperty("主键id") + private String id; + + /** + * 单据名称 + */ + @TableField("f_full_name") + @ApiModelProperty("单据名称") + private String fullName; + + /** + * 单据编码 + */ + @TableField("f_en_code") + @ApiModelProperty("单据编码") + private String enCode; + + /** + * 单据前缀 + */ + @TableField("f_prefix") + @ApiModelProperty("单据前缀") + private String prefix; + + /** + * 日期格式 + */ + @TableField("f_date_format") + @ApiModelProperty("日期格式") + private String dateFormat; + + /** + * 流水位数 + */ + @TableField("f_digit") + @ApiModelProperty("流水位数") + private Integer digit; + + /** + * 流水起始 + */ + @TableField("f_start_number") + @ApiModelProperty("流水起始") + private String startNumber; + + /** + * 流水范例 + */ + @TableField("f_example") + @ApiModelProperty("流水范例") + private String example; + + /** + * 当前流水号 + */ + @TableField("f_this_number") + @ApiModelProperty("当前流水号") + private Integer thisNumber; + + /** + * 输出流水号 + */ + @TableField("f_output_number") + @ApiModelProperty("输出流水号") + private String outputNumber; + + /** + * 分类 + */ + @TableField("f_category") + @ApiModelProperty("分类") + private String category; +} diff --git a/nxhs-service/src/main/java/cc/yunxi/domain/po/Recycler.java b/nxhs-service/src/main/java/cc/yunxi/domain/po/Recycler.java index 3b2807c..1a13bbf 100644 --- a/nxhs-service/src/main/java/cc/yunxi/domain/po/Recycler.java +++ b/nxhs-service/src/main/java/cc/yunxi/domain/po/Recycler.java @@ -26,24 +26,31 @@ public class Recycler { private String id; @ApiModelProperty("所属回收站") + @TableField(value = "station_id") private String stationId; @ApiModelProperty("回收员姓名") + @TableField(value = "staffs_name") private String staffsName; @ApiModelProperty("回收员电话") + @TableField(value = "mobile_phone") private String mobilePhone; @ApiModelProperty("头像") + @TableField(value = "head_icon") private String headIcon; @ApiModelProperty("性别") + @TableField(value = "gender") private Integer gender; @ApiModelProperty("总里程数") + @TableField(value = "recycle_miles") private Double recycleMiles; @ApiModelProperty("总订单数") + @TableField(value = "order_total") private Integer orderTotal; @ApiModelProperty("好评数") @@ -51,9 +58,11 @@ public class Recycler { private Integer goodTotal; @ApiModelProperty("总回收金额") + @TableField(value = "order_amount") private BigDecimal orderAmount; @ApiModelProperty("自动接单 (0-否,1-是) ") + @TableField(value = "auto_enabled") private Integer autoEnabled; @ApiModelProperty("状态 (0-禁用,1-启用)") @@ -61,6 +70,7 @@ public class Recycler { private Integer status; @ApiModelProperty("wxopenid") + @TableField(value = "openid") private String openid; @ApiModelProperty("商户id") diff --git a/nxhs-service/src/main/java/cc/yunxi/mapper/BillRuleMapper.java b/nxhs-service/src/main/java/cc/yunxi/mapper/BillRuleMapper.java new file mode 100644 index 0000000..46c072d --- /dev/null +++ b/nxhs-service/src/main/java/cc/yunxi/mapper/BillRuleMapper.java @@ -0,0 +1,14 @@ +package cc.yunxi.mapper; + +import cc.yunxi.domain.po.BillRule; +import cc.yunxi.domain.po.Recycler; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** + * 规则表 mapper接口 + */ +@Mapper +public interface BillRuleMapper extends BaseMapper { + +} diff --git a/nxhs-service/src/main/java/cc/yunxi/mapper/ClientMapper.java b/nxhs-service/src/main/java/cc/yunxi/mapper/ClientMapper.java index 1b829ea..1b74297 100644 --- a/nxhs-service/src/main/java/cc/yunxi/mapper/ClientMapper.java +++ b/nxhs-service/src/main/java/cc/yunxi/mapper/ClientMapper.java @@ -15,4 +15,6 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface ClientMapper extends BaseMapper { String isClientUnit(String phoneNumber); + + Client getLatestClientByPhone(String phone); } diff --git a/nxhs-service/src/main/java/cc/yunxi/mapper/RecyclerMapper.java b/nxhs-service/src/main/java/cc/yunxi/mapper/RecyclerMapper.java index e8438c9..754b0c4 100644 --- a/nxhs-service/src/main/java/cc/yunxi/mapper/RecyclerMapper.java +++ b/nxhs-service/src/main/java/cc/yunxi/mapper/RecyclerMapper.java @@ -1,14 +1,21 @@ package cc.yunxi.mapper; +import cc.yunxi.domain.po.PriceProduct; import cc.yunxi.domain.po.Recycler; import cc.yunxi.domain.po.Test; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; /** * 回收员表 mapper接口 */ @Mapper public interface RecyclerMapper extends BaseMapper { - + /** + * 根据phone 查询最新一条的有效的回收员 + * @param phone + * @return Price + */ + Recycler getLatestRecycleByPhone(@Param("phone") String phone); } diff --git a/nxhs-service/src/main/java/cc/yunxi/service/IBillRuleService.java b/nxhs-service/src/main/java/cc/yunxi/service/IBillRuleService.java new file mode 100644 index 0000000..6f03626 --- /dev/null +++ b/nxhs-service/src/main/java/cc/yunxi/service/IBillRuleService.java @@ -0,0 +1,35 @@ +package cc.yunxi.service; + +import cc.yunxi.domain.po.BillRule; +import cc.yunxi.domain.po.RecycleOrder; +import cc.yunxi.domain.query.RecycleOrderQuery; +import cc.yunxi.domain.vo.recycleorder.dzorder.DZRecycleOrderCreateVO; +import cc.yunxi.domain.vo.recycleorder.shorder.*; +import cc.yunxi.domain.vo.recycleorder.tmorder.TMRecycleOrderCreateVO; +import cc.yunxi.domain.vo.recycleorder.tmorder.TMRecycleOrderFinishVO; +import cc.yunxi.enums.OrderTypeEnum; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; + +import javax.validation.Valid; + +/** + *

+ * 回收站回收订单 服务类 + *

+ * + * @author ccongli + * @since 2024-03-01 11:15:39 + */ +public interface IBillRuleService extends IService { + + /** + * 规则详情 + * @param enCode + * @return BillRule + */ + BillRule getBillRuleByCode(String enCode); + + boolean updateById(BillRule billRule); + +} diff --git a/nxhs-service/src/main/java/cc/yunxi/service/IClientService.java b/nxhs-service/src/main/java/cc/yunxi/service/IClientService.java index 7b3976b..113272a 100644 --- a/nxhs-service/src/main/java/cc/yunxi/service/IClientService.java +++ b/nxhs-service/src/main/java/cc/yunxi/service/IClientService.java @@ -60,6 +60,7 @@ public interface IClientService extends IService { * @return Client */ Client getClientByMobile(String mobile); + Client getLastestClientByPhone(String phone); /** * 根据手机号注册散户信息 diff --git a/nxhs-service/src/main/java/cc/yunxi/service/IRecyclerService.java b/nxhs-service/src/main/java/cc/yunxi/service/IRecyclerService.java index a644fa6..e2d7d11 100644 --- a/nxhs-service/src/main/java/cc/yunxi/service/IRecyclerService.java +++ b/nxhs-service/src/main/java/cc/yunxi/service/IRecyclerService.java @@ -78,4 +78,6 @@ public interface IRecyclerService extends IService { */ void totalTick(String recyclerId, Double distance, BigDecimal amount); + Recycler getLatestRecycleByPhone(String phone); + } diff --git a/nxhs-service/src/main/java/cc/yunxi/service/RestTemplateToInterface.java b/nxhs-service/src/main/java/cc/yunxi/service/RestTemplateToInterface.java new file mode 100644 index 0000000..5906e44 --- /dev/null +++ b/nxhs-service/src/main/java/cc/yunxi/service/RestTemplateToInterface.java @@ -0,0 +1,39 @@ +package cc.yunxi.service; + +import cn.hutool.json.JSONObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.*; +import org.springframework.stereotype.Service; +import org.springframework.web.client.RestTemplate; + +@Service +public class RestTemplateToInterface { + + @Autowired + private RestTemplate restTemplate; + + /** + * exchange + * @return + */ + public String restPost(String url, Integer age, String name){ + //header参数 + HttpHeaders headers = new HttpHeaders(); + String token = "asdfaf2322"; + headers.add("authorization", token); + headers.setContentType(MediaType.APPLICATION_JSON); + + //放入body中的json参数 + JSONObject obj = new JSONObject(); + obj.put("age", age); + obj.put("name", name); + + //组装 + HttpEntity request = new HttpEntity<>(obj, headers); + ResponseEntity responseEntity = restTemplate.exchange(url, HttpMethod.POST, request, String.class); + String body = responseEntity.getBody(); + return body; + } + + +} diff --git a/nxhs-service/src/main/java/cc/yunxi/service/impl/BillRuleServiceImpl.java b/nxhs-service/src/main/java/cc/yunxi/service/impl/BillRuleServiceImpl.java new file mode 100644 index 0000000..118445f --- /dev/null +++ b/nxhs-service/src/main/java/cc/yunxi/service/impl/BillRuleServiceImpl.java @@ -0,0 +1,74 @@ +package cc.yunxi.service.impl; + +import cc.yunxi.common.domain.LambdaQueryWrapperX; +import cc.yunxi.common.exception.BizIllegalException; +import cc.yunxi.common.exception.BusinessLogicException; +import cc.yunxi.common.exception.ForbiddenException; +import cc.yunxi.common.utils.BeanUtils; +import cc.yunxi.common.utils.CommonUtil; +import cc.yunxi.domain.dto.LocationDTO; +import cc.yunxi.domain.po.*; +import cc.yunxi.domain.query.RecycleOrderQuery; +import cc.yunxi.domain.vo.recycleorder.dzorder.DZRecycleOrderCreateVO; +import cc.yunxi.domain.vo.recycleorder.shorder.*; +import cc.yunxi.domain.vo.recycleorder.tmorder.TMRecycleOrderCreateVO; +import cc.yunxi.domain.vo.recycleorder.tmorder.TMRecycleOrderFinishVO; +import cc.yunxi.domain.vo.recycleorderdetail.RecycleOrderDetailCreateVO; +import cc.yunxi.domain.vo.recycleorderdetail.RecycleOrderDetailSaveVO; +import cc.yunxi.enums.BusinessCodeEnum; +import cc.yunxi.enums.OrderStatusEnum; +import cc.yunxi.enums.OrderTypeEnum; +import cc.yunxi.enums.UserTypeEnum; +import cc.yunxi.mapper.BillRuleMapper; +import cc.yunxi.mapper.RecycleOrderMapper; +import cc.yunxi.service.*; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONArray; +import cn.hutool.json.JSONUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.List; + +/** + *

+ * 回收站回收订单 服务实现类 + *

+ * + * @author ccongli + * @since 2024-03-01 11:15:39 + */ +@Service +@Validated +@Slf4j +public class BillRuleServiceImpl extends ServiceImpl implements IBillRuleService { + + + + @Override + public BillRule getBillRuleByCode(String enCode) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(BillRule::getEnCode, enCode); + + BillRule entity = this.getOne(wrapper); + return entity; + } + + @Override + public boolean updateById(BillRule billRule) { + + return this.updateById(billRule); + } + + + +} diff --git a/nxhs-service/src/main/java/cc/yunxi/service/impl/ClientServiceImpl.java b/nxhs-service/src/main/java/cc/yunxi/service/impl/ClientServiceImpl.java index e841114..19d9a71 100644 --- a/nxhs-service/src/main/java/cc/yunxi/service/impl/ClientServiceImpl.java +++ b/nxhs-service/src/main/java/cc/yunxi/service/impl/ClientServiceImpl.java @@ -135,6 +135,11 @@ public class ClientServiceImpl extends ServiceImpl impleme return client; } + @Override + public Client getLastestClientByPhone(String phone) { + return clientMapper.getLatestClientByPhone(phone); + } + @Override @Transactional diff --git a/nxhs-service/src/main/java/cc/yunxi/service/impl/CommonService.java b/nxhs-service/src/main/java/cc/yunxi/service/impl/CommonService.java index 5a4fa1e..09456be 100644 --- a/nxhs-service/src/main/java/cc/yunxi/service/impl/CommonService.java +++ b/nxhs-service/src/main/java/cc/yunxi/service/impl/CommonService.java @@ -7,8 +7,10 @@ import cc.yunxi.config.props.WxHsyProperties; import cc.yunxi.config.props.WxShProperties; import cc.yunxi.domain.dto.UserDTO; import cc.yunxi.domain.dto.WxLoginDTO; +import cc.yunxi.domain.dto.ZSGLoginDTO; import cc.yunxi.domain.po.Client; import cc.yunxi.domain.po.Recycler; +import cc.yunxi.domain.query.RecyclerQuery; import cc.yunxi.enums.UserTypeEnum; import cc.yunxi.service.IClientService; import cc.yunxi.service.ICommonService; @@ -96,6 +98,32 @@ public class CommonService implements ICommonService { return userDTO; } + public ZSGLoginDTO loginByZSG(String loginName) { + + ZSGLoginDTO zsgLoginDTO = new ZSGLoginDTO(); + + Recycler recycler = recyclerService.getLatestRecycleByPhone(loginName); + Client client = clientService.getLastestClientByPhone(loginName); + if (recycler == null) { + if(client != null){ + // 设置投递员信息 + zsgLoginDTO.setId(Long.parseLong(client.getId())); + zsgLoginDTO.setLoginName(loginName); + zsgLoginDTO.setStat(client.getEnabledMark().equals(1)?0:2); + zsgLoginDTO.setRole(9); + zsgLoginDTO.setScore(client.getMembershipPoint()); + } + }else { + // 设置清运员信息 + zsgLoginDTO.setId(Long.parseLong(recycler.getId())); + zsgLoginDTO.setLoginName(loginName); + zsgLoginDTO.setStat(0); + zsgLoginDTO.setRole(4); + zsgLoginDTO.setScore(0); + } + + return zsgLoginDTO; + } @Override public UserDTO loginByRecycler(WxLoginDTO wxLoginDTO) { diff --git a/nxhs-service/src/main/java/cc/yunxi/service/impl/EnterpriseWalletServiceImpl.java b/nxhs-service/src/main/java/cc/yunxi/service/impl/EnterpriseWalletServiceImpl.java index 3810d85..f703cbe 100644 --- a/nxhs-service/src/main/java/cc/yunxi/service/impl/EnterpriseWalletServiceImpl.java +++ b/nxhs-service/src/main/java/cc/yunxi/service/impl/EnterpriseWalletServiceImpl.java @@ -4,10 +4,7 @@ import cc.yunxi.common.domain.LambdaQueryWrapperX; import cc.yunxi.common.exception.BizIllegalException; import cc.yunxi.common.utils.BeanUtils; import cc.yunxi.common.utils.CommonUtil; -import cc.yunxi.domain.po.Enterprise; -import cc.yunxi.domain.po.EnterpriseAccountBill; -import cc.yunxi.domain.po.EnterpriseWallet; -import cc.yunxi.domain.po.RecycleStation; +import cc.yunxi.domain.po.*; import cc.yunxi.domain.query.WalletQuery; import cc.yunxi.domain.vo.enterprise.WalletVO; import cc.yunxi.enums.BusinessCodeEnum; @@ -15,6 +12,7 @@ import cc.yunxi.enums.GlobalStatusEnum; import cc.yunxi.mapper.EnterpriseAccountBillMapper; import cc.yunxi.mapper.EnterpriseMapper; import cc.yunxi.mapper.WalletMapper; +import cc.yunxi.service.IBillRuleService; import cc.yunxi.service.IEnterpriseService; import cc.yunxi.service.IEnterpriseWalletService; import cc.yunxi.service.IRecycleStationService; @@ -30,7 +28,9 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.math.BigDecimal; import java.math.RoundingMode; +import java.text.SimpleDateFormat; import java.time.LocalDateTime; +import java.util.Date; /** *

@@ -46,6 +46,9 @@ public class EnterpriseWalletServiceImpl extends ServiceImpl wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(BillRule::getEnCode, enCode); + + BillRule entity = billRuleService.getBillRuleByCode(enCode); + + + if (entity != null) { + Integer startNumber = Integer.parseInt(entity.getStartNumber()); + String dateFor = entity.getDateFormat(); + //处理隔天流水号归0 + if (entity.getOutputNumber() != null) { + String serialDate; + entity.setThisNumber(entity.getThisNumber() + 1); + if (!"no".equals(dateFor)) { + String thisDate = CommonUtil.dateNow(entity.getDateFormat()); + serialDate = entity.getOutputNumber().substring((entity.getOutputNumber().length() - dateFor.length() - entity.getDigit()), (entity.getOutputNumber().length() - entity.getDigit())); + if (!serialDate.equals(thisDate)) { + entity.setThisNumber(0); + } + } + } else { + entity.setThisNumber(0); + } + //拼接单据编码 + strNumber.append(entity.getPrefix()); + if (!"no".equals(dateFor)) { + strNumber.append(CommonUtil.dateNow(entity.getDateFormat())); + } + strNumber.append(CommonUtil.padRight(String.valueOf((startNumber) + entity.getThisNumber()), entity.getDigit(), '0')); + //更新流水号 + entity.setOutputNumber(strNumber.toString()); + billRuleService.updateById(entity); + } + return strNumber.toString(); + } + + } diff --git a/nxhs-service/src/main/java/cc/yunxi/service/impl/RecyclerServiceImpl.java b/nxhs-service/src/main/java/cc/yunxi/service/impl/RecyclerServiceImpl.java index 673fb39..307c6c9 100644 --- a/nxhs-service/src/main/java/cc/yunxi/service/impl/RecyclerServiceImpl.java +++ b/nxhs-service/src/main/java/cc/yunxi/service/impl/RecyclerServiceImpl.java @@ -83,6 +83,11 @@ public class RecyclerServiceImpl extends ServiceImpl i return recycler; } + @Override + public Recycler getLatestRecycleByPhone(String phone) { + return recyclerMapper.getLatestRecycleByPhone(phone); + } + @Override public List getRecyclerByIds(Collection recyclerIds) { LambdaQueryWrapperX wrapperX = new LambdaQueryWrapperX<>(); diff --git a/nxhs-service/src/main/resources/mapper/ClientMapper.xml b/nxhs-service/src/main/resources/mapper/ClientMapper.xml index 9e1eb86..5e1cc82 100644 --- a/nxhs-service/src/main/resources/mapper/ClientMapper.xml +++ b/nxhs-service/src/main/resources/mapper/ClientMapper.xml @@ -7,4 +7,8 @@ SELECT id,name FROM nx_manager where mobile_phone = #{phoneNumber}; + + diff --git a/nxhs-service/src/main/resources/mapper/RecyclerMapper.xml b/nxhs-service/src/main/resources/mapper/RecyclerMapper.xml index 807c4a4..d9c2e7b 100644 --- a/nxhs-service/src/main/resources/mapper/RecyclerMapper.xml +++ b/nxhs-service/src/main/resources/mapper/RecyclerMapper.xml @@ -1,5 +1,7 @@ - - + +