diff --git a/src/main/java/com/sczx/sync/common/Result.java b/src/main/java/com/sczx/sync/common/Result.java index 9126fd9..d82bac2 100644 --- a/src/main/java/com/sczx/sync/common/Result.java +++ b/src/main/java/com/sczx/sync/common/Result.java @@ -81,6 +81,12 @@ public class Result implements Serializable { return ok(map); } + public static Result ok(String code, String msg, String issue,String key, Object value) { + Map map = new HashMap(1); + map.put(key, value); + return builder().code(code).success(true).msg(msg).issue(issue).data(map).build(); + } + public static Result fail(String msg) { return result((IApiCode)ApiErrorCode.FAIL, msg, msg, (Object)null); } diff --git a/src/main/java/com/sczx/sync/controller/ReceiveBatteryController.java b/src/main/java/com/sczx/sync/controller/ReceiveBatteryController.java index bb9bd51..bc84ce0 100644 --- a/src/main/java/com/sczx/sync/controller/ReceiveBatteryController.java +++ b/src/main/java/com/sczx/sync/controller/ReceiveBatteryController.java @@ -35,7 +35,7 @@ public class ReceiveBatteryController { @ApiOperation(value = "接收租电数据接口") @PostMapping("/batterymeal") - public Result batterymeal(@RequestBody String receiveMealReq){ + public Result batteryMeal(@RequestBody String receiveMealReq){ Boolean bool = receiveService.recceiveMeals(receiveMealReq); if (!bool.booleanValue()){ return Result.fail(NOT_PERMISSION); @@ -43,6 +43,35 @@ public class ReceiveBatteryController { return Result.ok(); } + @ApiOperation(value = "接收用户数据接口") + @PostMapping("/userinfo") + public Result userInfo(@RequestBody String receiveMealReq){ + String code = receiveService.recceiveUserInfo(receiveMealReq); + if (code.equals(NOT_PERMISSION.getCode())){ + return Result.fail(NOT_PERMISSION); + } + return Result.ok("200","操作成功","操作成功","Cid",code); + } + + @ApiOperation(value = "接收运营商数据接口") + @PostMapping("/companyinfo") + public Result companyInfo(@RequestBody String receiveMealReq){ + String code = receiveService.recceiveCompanyInfo(receiveMealReq); + if (code.equals(NOT_PERMISSION.getCode())){ + return Result.fail(NOT_PERMISSION); + } + return Result.ok("200","操作成功","操作成功","Cid",code); + } + + @ApiOperation(value = "接收门店数据接口") + @PostMapping("/storeinfo") + public Result storeInfo(@RequestBody String receiveMealReq){ + String code = receiveService.recceiveStoreInfo(receiveMealReq); + if (code.equals(NOT_PERMISSION.getCode())){ + return Result.fail(NOT_PERMISSION); + } + return Result.ok("200","操作成功","操作成功","Cid",code); + } diff --git a/src/main/java/com/sczx/sync/entity/UserInfo.java b/src/main/java/com/sczx/sync/entity/UserInfo.java new file mode 100644 index 0000000..8c1797f --- /dev/null +++ b/src/main/java/com/sczx/sync/entity/UserInfo.java @@ -0,0 +1,163 @@ +package com.sczx.sync.entity; + +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + * 用户信息实体类 + */ +public class UserInfo implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 微信unionid + */ + private String wxunionid; + + /** + * 我的微信unionid + */ + private String mywxunionid; + + /** + * 手机号 + */ + private String phone; + + /** + * 是否认证 + */ + private Integer isauthentication; + + /** + * 姓名 + */ + private String name; + + /** + * 身份证号 + */ + private String cardno; + + /** + * 身份证正面 + */ + private String card1; + + /** + * 身份证反面 + */ + private String card2; + + /** + * 是否商户 + */ + private Integer ismerchant; + + /** + * 运营商ID + */ + private String operatorId; + + /** + * 门店ID + */ + private String storeId; + + private LocalDateTime syncTime; + public LocalDateTime getSyncTime() { + return syncTime; + } + + public void setSyncTime(LocalDateTime syncTime) { + this.syncTime = syncTime; + } + + public String getWxunionid() { + return wxunionid; + } + + public void setWxunionid(String wxunionid) { + this.wxunionid = wxunionid; + } + + public String getMywxunionid() { + return mywxunionid; + } + + public void setMywxunionid(String mywxunionid) { + this.mywxunionid = mywxunionid; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public Integer getIsauthentication() { + return isauthentication; + } + + public void setIsauthentication(Integer isauthentication) { + this.isauthentication = isauthentication; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getCardno() { + return cardno; + } + + public void setCardno(String cardno) { + this.cardno = cardno; + } + + public String getCard1() { + return card1; + } + + public void setCard1(String card1) { + this.card1 = card1; + } + + public String getCard2() { + return card2; + } + + public void setCard2(String card2) { + this.card2 = card2; + } + + public Integer getIsmerchant() { + return ismerchant; + } + + public void setIsmerchant(Integer ismerchant) { + this.ismerchant = ismerchant; + } + + public String getOperatorId() { + return operatorId; + } + + public void setOperatorId(String operatorId) { + this.operatorId = operatorId; + } + + public String getStoreId() { + return storeId; + } + + public void setStoreId(String storeId) { + this.storeId = storeId; + } +} diff --git a/src/main/java/com/sczx/sync/mapper/BaseUserMapper.java b/src/main/java/com/sczx/sync/mapper/BaseUserMapper.java new file mode 100644 index 0000000..547f485 --- /dev/null +++ b/src/main/java/com/sczx/sync/mapper/BaseUserMapper.java @@ -0,0 +1,39 @@ +package com.sczx.sync.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sczx.sync.po.BaseUser; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * 租车用户信息 Mapper 接口 + */ +@Mapper +public interface BaseUserMapper extends BaseMapper { + + /** + * 根据手机号查询用户 + * @param phoneNumber 手机号 + * @return 用户信息 + */ + BaseUser selectByPhoneNumber(@Param("phoneNumber") String phoneNumber); + + + /** + * 插入用户信息 + * @param user 用户信息 + * @return 影响行数 + */ + int insertBaseUser(BaseUser user); + + + + /** + * 根据手机号更新用户信息 + * @param user 用户信息 + * @return 影响行数 + */ + int updateByPhoneNumber(BaseUser user); + + +} diff --git a/src/main/java/com/sczx/sync/mapper/BatteryMealMapper.java b/src/main/java/com/sczx/sync/mapper/BatteryMealMapper.java index 27e6e47..aba3a97 100644 --- a/src/main/java/com/sczx/sync/mapper/BatteryMealMapper.java +++ b/src/main/java/com/sczx/sync/mapper/BatteryMealMapper.java @@ -1,13 +1,13 @@ package com.sczx.sync.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.sczx.sync.po.SyncDataInfo; +import com.sczx.sync.po.BatteryRule; import org.apache.ibatis.annotations.Mapper; @Mapper -public interface BatteryMealMapper extends BaseMapper { +public interface BatteryMealMapper extends BaseMapper { - int insertZcRentBatteyRule(SyncDataInfo syncDataInfo); + int insertZcRentBatteyRule(BatteryRule batteryRule); - int updateBatteryRule(SyncDataInfo syncDataInfo); + int updateBatteryRule(BatteryRule batteryRule); } diff --git a/src/main/java/com/sczx/sync/mapper/CompanyInfoMapper.java b/src/main/java/com/sczx/sync/mapper/CompanyInfoMapper.java new file mode 100644 index 0000000..ef3f264 --- /dev/null +++ b/src/main/java/com/sczx/sync/mapper/CompanyInfoMapper.java @@ -0,0 +1,50 @@ +package com.sczx.sync.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sczx.sync.po.CompanyInfo; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * 公司信息 Mapper 接口 + */ +@Mapper +public interface CompanyInfoMapper extends BaseMapper { + + /** + * 根据电话号码查询公司信息 + * @param phone 电话号码 + * @return 公司信息 + */ + CompanyInfo selectByPhone(@Param("phone") String phone); + + /** + * 根据opid查询公司信息 + * @param bOpId 电话号码 + * @return 公司信息 + */ + CompanyInfo selectByOpId(@Param("bOpId") Long bOpId); + + /** + * 根据电话号码更新公司信息 + * @param companyInfo 公司信息 + * @return 影响行数 + */ + int updateByPhone(CompanyInfo companyInfo); + + int updateByOpId(CompanyInfo companyInfo); + + /** + * 插入公司信息 + * @param companyInfo 公司信息 + * @return 影响行数 + */ + int insertCompanyInfo(CompanyInfo companyInfo); + + /** + * 根据公司名称查询公司信息 + * @param companyName 公司名称 + * @return 公司信息 + */ + CompanyInfo selectByCompanyName(@Param("companyName") String companyName); +} diff --git a/src/main/java/com/sczx/sync/mapper/CompanyStoreMapper.java b/src/main/java/com/sczx/sync/mapper/CompanyStoreMapper.java index 7558b4c..6a17425 100644 --- a/src/main/java/com/sczx/sync/mapper/CompanyStoreMapper.java +++ b/src/main/java/com/sczx/sync/mapper/CompanyStoreMapper.java @@ -1,13 +1,45 @@ package com.sczx.sync.mapper; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sczx.sync.po.StoreInfo; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; @Mapper -public interface CompanyStoreMapper { +public interface CompanyStoreMapper extends BaseMapper { int updateStoreId(long bpStoreId, long cId); int updateOpeId(long bOpId, long cId); int updateOdId(long bOdId, long cId); + + + /** + * 根据联系电话查询门店信息 + * @param phone 联系电话 + * @return 门店信息 + */ + StoreInfo selectByPhone(@Param("phone") String phone); + + StoreInfo selectByBid(@Param("bpStoreId") Long bpStoreId); + + + /** + * 根据门店名称更新门店信息 + * @param storeInfo 门店信息 + * @return 影响行数 + */ + int updateByName(StoreInfo storeInfo); + + + int updateByBid(StoreInfo storeInfo); + /** + * 插入门店信息 + * @param storeInfo 门店信息 + * @return 影响行数 + */ + int insertStoreInfo(StoreInfo storeInfo); + + } diff --git a/src/main/java/com/sczx/sync/mapper/UserStoreMapper.java b/src/main/java/com/sczx/sync/mapper/UserStoreMapper.java new file mode 100644 index 0000000..1fddf79 --- /dev/null +++ b/src/main/java/com/sczx/sync/mapper/UserStoreMapper.java @@ -0,0 +1,34 @@ +package com.sczx.sync.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sczx.sync.po.UserStore; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * 用户与门店信息 Mapper 接口 + */ +@Mapper +public interface UserStoreMapper extends BaseMapper { + + /** + * 根据用户ID查询用户门店信息 + * @param userId 用户ID + * @return 用户门店信息 + */ + UserStore selectByUserId(@Param("userId") Long userId); + + /** + * 根据用户ID更新用户门店信息 + * @param userStore 用户门店信息 + * @return 影响行数 + */ + int updateByUserId(UserStore userStore); + + /** + * 插入用户门店信息 + * @param userStore 用户门店信息 + * @return 影响行数 + */ + int insertUserStore(UserStore userStore); +} diff --git a/src/main/java/com/sczx/sync/po/BaseUser.java b/src/main/java/com/sczx/sync/po/BaseUser.java new file mode 100644 index 0000000..499f44f --- /dev/null +++ b/src/main/java/com/sczx/sync/po/BaseUser.java @@ -0,0 +1,295 @@ +package com.sczx.sync.po; + +import com.baomidou.mybatisplus.annotation.*; +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + * 租车用户信息实体类 + */ +@TableName("zc_base_user") +public class BaseUser implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 用户id主键 + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 用户名 + */ + @TableField("user_name") + private String userName; + + /** + * 头像 + */ + @TableField("avatar_url") + private String avatarUrl; + + /** + * 密码 + */ + @TableField("password") + private String password; + + /** + * 手机号 + */ + @TableField("phone_number") + private String phoneNumber; + + /** + * 角色id + */ + @TableField("role_id") + private Integer roleId; + + /** + * 是否门店用户1是0否 + */ + @TableField("is_store") + private Integer isStore; + + /** + * 昵称 + */ + @TableField("nick_name") + private String nickName; + + /** + * 微信小程序 openid + */ + @TableField("wechat_openid") + private String wechatOpenid; + + /** + * 运营商ID + */ + @TableField("operator_id") + private Integer operatorId; + + /** + * 门店ID + */ + @TableField("store_id") + private Integer storeId; + + /** + * 支付宝小程序 userid + */ + @TableField("alipay_userid") + private String alipayUserid; + + /** + * 是否认证,0未认证1已认证 + */ + @TableField("authed") + private Integer authed; + + /** + * 身份证号 + */ + @TableField("id_no") + private String idNo; + + /** + * 真实姓名 + */ + @TableField("real_name") + private String realName; + + /** + * 正面照片 + */ + @TableField("front_photo") + private String frontPhoto; + + /** + * 反面照片 + */ + @TableField("back_photo") + private String backPhoto; + + /** + * 删除标志(0代表存在 2代表删除) + */ + @TableField("del_flag") + private String delFlag; + + /** + * 创建时间 + */ + @TableField(value = "create_time", fill = FieldFill.INSERT) + private LocalDateTime createTime; + + /** + * 更新时间 + */ + @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) + private LocalDateTime updateTime; + + // Getters and Setters + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getAvatarUrl() { + return avatarUrl; + } + + public void setAvatarUrl(String avatarUrl) { + this.avatarUrl = avatarUrl; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getPhoneNumber() { + return phoneNumber; + } + + public void setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + } + + public Integer getRoleId() { + return roleId; + } + + public void setRoleId(Integer roleId) { + this.roleId = roleId; + } + + public Integer getIsStore() { + return isStore; + } + + public void setIsStore(Integer isStore) { + this.isStore = isStore; + } + + public String getNickName() { + return nickName; + } + + public void setNickName(String nickName) { + this.nickName = nickName; + } + + public String getWechatOpenid() { + return wechatOpenid; + } + + public void setWechatOpenid(String wechatOpenid) { + this.wechatOpenid = wechatOpenid; + } + + public Integer getOperatorId() { + return operatorId; + } + + public void setOperatorId(Integer operatorId) { + this.operatorId = operatorId; + } + + public Integer getStoreId() { + return storeId; + } + + public void setStoreId(Integer storeId) { + this.storeId = storeId; + } + + public String getAlipayUserid() { + return alipayUserid; + } + + public void setAlipayUserid(String alipayUserid) { + this.alipayUserid = alipayUserid; + } + + public Integer getAuthed() { + return authed; + } + + public void setAuthed(Integer authed) { + this.authed = authed; + } + + public String getIdNo() { + return idNo; + } + + public void setIdNo(String idNo) { + this.idNo = idNo; + } + + public String getRealName() { + return realName; + } + + public void setRealName(String realName) { + this.realName = realName; + } + + public String getFrontPhoto() { + return frontPhoto; + } + + public void setFrontPhoto(String frontPhoto) { + this.frontPhoto = frontPhoto; + } + + public String getBackPhoto() { + return backPhoto; + } + + public void setBackPhoto(String backPhoto) { + this.backPhoto = backPhoto; + } + + public String getDelFlag() { + return delFlag; + } + + public void setDelFlag(String delFlag) { + this.delFlag = delFlag; + } + + public LocalDateTime getCreateTime() { + return createTime; + } + + public void setCreateTime(LocalDateTime createTime) { + this.createTime = createTime; + } + + public LocalDateTime getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(LocalDateTime updateTime) { + this.updateTime = updateTime; + } +} diff --git a/src/main/java/com/sczx/sync/po/SyncDataInfo.java b/src/main/java/com/sczx/sync/po/BatteryRule.java similarity index 98% rename from src/main/java/com/sczx/sync/po/SyncDataInfo.java rename to src/main/java/com/sczx/sync/po/BatteryRule.java index 8d705b0..5ebe26a 100644 --- a/src/main/java/com/sczx/sync/po/SyncDataInfo.java +++ b/src/main/java/com/sczx/sync/po/BatteryRule.java @@ -7,7 +7,7 @@ import java.io.Serializable; import java.time.LocalDateTime; @TableName("zc_rent_battey_rule") -public class SyncDataInfo implements Serializable { +public class BatteryRule implements Serializable { private static final long serialVersionUID = 1L; @TableField("id") private Long id; @@ -35,7 +35,7 @@ public class SyncDataInfo implements Serializable { private Integer categoryId; @TableField("operator_id") private Integer operatorId; - + private LocalDateTime syncTime; public LocalDateTime getSyncTime() { return syncTime; } @@ -44,7 +44,7 @@ public class SyncDataInfo implements Serializable { this.syncTime = syncTime; } - private LocalDateTime syncTime; + // Getters and Setters public void setId(Long id) { this.id = id;} diff --git a/src/main/java/com/sczx/sync/po/CompanyInfo.java b/src/main/java/com/sczx/sync/po/CompanyInfo.java new file mode 100644 index 0000000..7886a6b --- /dev/null +++ b/src/main/java/com/sczx/sync/po/CompanyInfo.java @@ -0,0 +1,113 @@ +package com.sczx.sync.po; + +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; + +@Data +public class CompanyInfo implements Serializable { + private static final long serialVersionUID = 1L; + + private Long id; + + private Long bOpId; + /** + * 公司名称 + */ + private String companyName; + + /** + * 联系人姓名 + */ + private String contactName; + + /** + * 电话号码 + */ + private String phone; + + /** + * 地址 + */ + private String address; + + /** + * 城市信息 + */ + private String citys; + + /** + * 是否删除标记 (0-未删除, 1-已删除) + */ + private Integer isDelete; + + /** + * 同步时间 + */ + private LocalDateTime syncTime; + + public Long getbOpId() { + return bOpId; + } + + public void setbOpId(Long bOpId) { + this.bOpId = bOpId; + } + + public String getCompanyName() { + return companyName; + } + + public void setCompanyName(String companyName) { + this.companyName = companyName; + } + + public String getContactName() { + return contactName; + } + + public void setContactName(String contactName) { + this.contactName = contactName; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getCitys() { + return citys; + } + + public void setCitys(String citys) { + this.citys = citys; + } + + public Integer getIsDelete() { + return isDelete; + } + + public void setIsDelete(Integer isDelete) { + this.isDelete = isDelete; + } + + public LocalDateTime getSyncTime() { + return syncTime; + } + + public void setSyncTime(LocalDateTime syncTime) { + this.syncTime = syncTime; + } +} diff --git a/src/main/java/com/sczx/sync/po/StoreInfo.java b/src/main/java/com/sczx/sync/po/StoreInfo.java new file mode 100644 index 0000000..884f9db --- /dev/null +++ b/src/main/java/com/sczx/sync/po/StoreInfo.java @@ -0,0 +1,169 @@ +package com.sczx.sync.po; + + +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + * 门店信息实体类 + */ +@Data +public class StoreInfo implements Serializable { + private static final long serialVersionUID = 1L; + + private Long id; + /** + * 门店名称 + */ + private String name; + + /** + * 联系人姓名 + */ + private String contactName; + + /** + * 联系电话 + */ + private String phone; + + /** + * 省份 + */ + private String province; + + /** + * 城市 + */ + private String city; + + /** + * 区域 + */ + private String area; + + /** + * 详细地址 + */ + private String address; + + /** + * 门店图片 + */ + private String image; + + /** + * 纬度 + */ + private Double latitude; + + /** + * 经度 + */ + private Double longitude; + + /** + * 是否删除标记 (0-未删除, 1-已删除) + */ + private Integer isDelete; + + private Long bpStoreId; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getContactName() { + return contactName; + } + + public void setContactName(String contactName) { + this.contactName = contactName; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getProvince() { + return province; + } + + public void setProvince(String province) { + this.province = province; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getImage() { + return image; + } + + public void setImage(String image) { + this.image = image; + } + + public Double getLatitude() { + return latitude; + } + + public void setLatitude(Double latitude) { + this.latitude = latitude; + } + + public Double getLongitude() { + return longitude; + } + + public void setLongitude(Double longitude) { + this.longitude = longitude; + } + + public Integer getIsDelete() { + return isDelete; + } + + public void setIsDelete(Integer isDelete) { + this.isDelete = isDelete; + } + + public Long getBpStoreId() { + return bpStoreId; + } + + public void setBpStoreId(Long bpStoreId) { + this.bpStoreId = bpStoreId; + } +} diff --git a/src/main/java/com/sczx/sync/po/SyncRequest.java b/src/main/java/com/sczx/sync/po/SyncRequest.java index ed252fe..0ec641e 100644 --- a/src/main/java/com/sczx/sync/po/SyncRequest.java +++ b/src/main/java/com/sczx/sync/po/SyncRequest.java @@ -3,7 +3,7 @@ package com.sczx.sync.po; import com.baomidou.mybatisplus.annotation.TableField; import java.io.Serializable; -public class SyncRequest implements Serializable { +public class SyncRequest implements Serializable { // 添加泛型参数 private static final long serialVersionUID = 1L; private String appid; @@ -11,7 +11,7 @@ public class SyncRequest implements Serializable { private String accessToken; @TableField("Data") - private SyncDataInfo data; + private T data; // 将 SyncDataInfo 改为 T // Getters and Setters public String getAppid() { @@ -30,13 +30,11 @@ public class SyncRequest implements Serializable { this.accessToken = accessToken; } - public SyncDataInfo getData() { + public T getData() { // 返回类型改为 T return data; } - public void setData(SyncDataInfo data) { + public void setData(T data) { // 参数类型改为 T this.data = data; } - - -} \ No newline at end of file +} diff --git a/src/main/java/com/sczx/sync/po/UserStore.java b/src/main/java/com/sczx/sync/po/UserStore.java new file mode 100644 index 0000000..6c523e4 --- /dev/null +++ b/src/main/java/com/sczx/sync/po/UserStore.java @@ -0,0 +1,141 @@ +package com.sczx.sync.po; + +import com.baomidou.mybatisplus.annotation.*; +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + * 用户与门店信息实体类 + */ +@TableName("zc_base_user_store") +public class UserStore implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * id主键 + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 用户id + */ + @TableField("user_id") + private Long userId; + + /** + * 运营商ID + */ + @TableField("operator_id") + private Long operatorId; + + /** + * 门店ID + */ + @TableField("store_id") + private Long storeId; + + /** + * 删除标志(0代表存在 2代表删除) + */ + @TableField("del_flag") + private String delFlag; + + /** + * 创建人 + */ + @TableField("create_by") + private String createBy; + + /** + * 创建时间 + */ + @TableField(value = "create_time", fill = FieldFill.INSERT) + private LocalDateTime createTime; + + /** + * 更新人 + */ + @TableField("update_by") + private String updateBy; + + /** + * 更新时间 + */ + @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) + private LocalDateTime updateTime; + + // Getters and Setters + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + + public Long getOperatorId() { + return operatorId; + } + + public void setOperatorId(Long operatorId) { + this.operatorId = operatorId; + } + + public Long getStoreId() { + return storeId; + } + + public void setStoreId(Long storeId) { + this.storeId = storeId; + } + + public String getDelFlag() { + return delFlag; + } + + public void setDelFlag(String delFlag) { + this.delFlag = delFlag; + } + + public String getCreateBy() { + return createBy; + } + + public void setCreateBy(String createBy) { + this.createBy = createBy; + } + + public LocalDateTime getCreateTime() { + return createTime; + } + + public void setCreateTime(LocalDateTime createTime) { + this.createTime = createTime; + } + + public String getUpdateBy() { + return updateBy; + } + + public void setUpdateBy(String updateBy) { + this.updateBy = updateBy; + } + + public LocalDateTime getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(LocalDateTime updateTime) { + this.updateTime = updateTime; + } +} diff --git a/src/main/java/com/sczx/sync/service/ReceiveService.java b/src/main/java/com/sczx/sync/service/ReceiveService.java index 3163edc..47cbb28 100644 --- a/src/main/java/com/sczx/sync/service/ReceiveService.java +++ b/src/main/java/com/sczx/sync/service/ReceiveService.java @@ -1,8 +1,12 @@ package com.sczx.sync.service; -import com.sczx.sync.dto.ReceiveMealReq; - public interface ReceiveService { boolean recceiveMeals(String request); + + String recceiveUserInfo(String request); + + String recceiveCompanyInfo(String request); + + String recceiveStoreInfo(String request); } diff --git a/src/main/java/com/sczx/sync/service/impl/ReceiveServiceImpl.java b/src/main/java/com/sczx/sync/service/impl/ReceiveServiceImpl.java index f227830..a1d7455 100644 --- a/src/main/java/com/sczx/sync/service/impl/ReceiveServiceImpl.java +++ b/src/main/java/com/sczx/sync/service/impl/ReceiveServiceImpl.java @@ -1,28 +1,26 @@ package com.sczx.sync.service.impl; import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; +import com.alibaba.nacos.common.utils.MD5Utils; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.sczx.sync.dto.DataRceiveReq; -import com.sczx.sync.dto.ReceiveMealReq; -import com.sczx.sync.mapper.BatteryMealMapper; -import com.sczx.sync.mapper.CompanyStoreMapper; -import com.sczx.sync.mapper.DataReceiveRecordMapper; -import com.sczx.sync.po.DataReceivePo; -import com.sczx.sync.po.SyncDataInfo; +import com.sczx.sync.mapper.*; +import com.sczx.sync.po.StoreInfo; +import com.sczx.sync.po.CompanyInfo; +import com.sczx.sync.po.BaseUser; +import com.sczx.sync.po.BatteryRule; import com.sczx.sync.po.SyncRequest; +import com.sczx.sync.entity.UserInfo; +import com.sczx.sync.po.UserStore; import com.sczx.sync.service.ReceiveService; -import com.sczx.sync.service.ThirdPartyForwardService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Component; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import java.time.LocalDateTime; -import java.util.Map; + +import static com.sczx.sync.common.enums.ApiErrorCode.NOT_PERMISSION; @Slf4j @Service @@ -32,7 +30,14 @@ public class ReceiveServiceImpl implements ReceiveService { @Autowired private BatteryMealMapper batteryMealMapper; - + @Autowired + private BaseUserMapper baseUserMapper; + @Autowired + private UserStoreMapper userStoreMapper; + @Autowired + private CompanyInfoMapper companyInfoMapper; + @Autowired + private CompanyStoreMapper companyStoreMapper; @Value("${battery-platform.appid}") private String appId; @@ -42,24 +47,116 @@ public class ReceiveServiceImpl implements ReceiveService { @Override public boolean recceiveMeals(String request) { - SyncRequest meals = JSON.parseObject(request, SyncRequest.class); + SyncRequest syncRequest = JSON.parseObject(request, SyncRequest.class); - if(!meals.getAppid().equals(appId)||!meals.getAccessToken().equals(accessToken)){ + if(!syncRequest.getAppid().equals(appId)||!syncRequest.getAccessToken().equals(accessToken)){ return false; } - SyncDataInfo syncDataInfo = meals.getData(); - syncDataInfo.setSyncTime(LocalDateTime.now()); - QueryWrapper syncDataInfoQueryWrapper = new QueryWrapper<>(); - QueryWrapper eq = syncDataInfoQueryWrapper.eq("meal_id", meals.getData().getMealId()); - if(batteryMealMapper.selectOne(eq)!=null){ + BatteryRule batteryRule = syncRequest.getData(); + batteryRule.setSyncTime(LocalDateTime.now()); + QueryWrapper syncDataInfoQueryWrapper = new QueryWrapper<>(); + QueryWrapper eq = syncDataInfoQueryWrapper.eq("meal_id", batteryRule.getMealId()); - batteryMealMapper.updateBatteryRule(syncDataInfo); - }else { - batteryMealMapper.insertZcRentBatteyRule(syncDataInfo); + if (batteryMealMapper.selectOne(eq) != null) { + batteryMealMapper.updateBatteryRule(batteryRule); + } else { + batteryMealMapper.insertZcRentBatteyRule(batteryRule); } - - return true; } + + @Override + public String recceiveUserInfo(String request) { + + SyncRequest syncRequest = JSON.parseObject(request, SyncRequest.class); + + if(!syncRequest.getAppid().equals(appId)||!syncRequest.getAccessToken().equals(accessToken)){ + return NOT_PERMISSION.getCode(); + } + UserInfo user = JSON.parseObject(String.valueOf(syncRequest.getData()), UserInfo.class); + + BaseUser baseUser = new BaseUser(); + + baseUser.setUserName(user.getPhone()); + baseUser.setPhoneNumber(user.getPhone()); + baseUser.setPassword(MD5Utils.md5Hex(user.getPhone(), "utf8")); + baseUser.setNickName(user.getPhone()); + baseUser.setRealName(user.getName()); + baseUser.setIdNo(user.getCardno()); + baseUser.setAuthed(user.getIsauthentication()); + baseUser.setIsStore(user.getIsmerchant()); + baseUser.setFrontPhoto(user.getCard1());; + baseUser.setBackPhoto(user.getCard2()); + baseUser.setDelFlag("0"); + + int baseUserId; + //处理baseuser + if (baseUserMapper.selectByPhoneNumber(user.getPhone()) != null) { + baseUserId = baseUserMapper.updateByPhoneNumber(baseUser); + } else { + baseUserId = baseUserMapper.insertBaseUser(baseUser); + } + + + UserStore userStore = new UserStore(); + String storeIds = user.getStoreId(); + String[] storeIdsArray = storeIds.split(","); + for (String storeId : storeIdsArray) { + userStore.setStoreId(Long.parseLong(storeId)); + userStore.setOperatorId(Long.parseLong(user.getOperatorId())); + userStore.setUserId(Long.parseLong(String.valueOf(baseUserId))); + userStore.setDelFlag("0"); + userStore.setCreateTime(LocalDateTime.now()); + userStore.setUpdateTime(LocalDateTime.now()); + userStoreMapper.insertUserStore(userStore) ; + } + + + return baseUserId + ""; + } + + @Override + public String recceiveCompanyInfo(String request) { + SyncRequest syncRequest = JSON.parseObject(request, SyncRequest.class); + + if(!syncRequest.getAppid().equals(appId)||!syncRequest.getAccessToken().equals(accessToken)){ + return NOT_PERMISSION.getCode(); + } + CompanyInfo companyInfo = JSON.parseObject(String.valueOf(syncRequest.getData()), CompanyInfo.class); + + if (companyInfoMapper.selectByCompanyName(companyInfo.getCompanyName())!=null){ + + } + + if(companyInfoMapper.selectByOpId(companyInfo.getbOpId()) != null){ + companyInfoMapper.updateByOpId(companyInfo); + } else if(companyInfoMapper.selectByPhone(companyInfo.getPhone())!=null){ + companyInfoMapper.updateByPhone(companyInfo); + }else { + companyInfoMapper.insertCompanyInfo(companyInfo); + } + return companyInfo.getId() + ""; + } + + @Override + public String recceiveStoreInfo(String request) { + SyncRequest syncRequest = JSON.parseObject(request, SyncRequest.class); + + if(!syncRequest.getAppid().equals(appId)||!syncRequest.getAccessToken().equals(accessToken)){ + return NOT_PERMISSION.getCode(); + } + + StoreInfo storeInfo = JSON.parseObject(String.valueOf(syncRequest.getData()), StoreInfo.class); + if(companyStoreMapper.selectByBid(storeInfo.getBpStoreId()) != null){ + companyStoreMapper.updateByBid(storeInfo); + } else if(companyStoreMapper.selectByPhone(storeInfo.getPhone())!=null){ + companyStoreMapper.updateByName(storeInfo); + }else { + companyStoreMapper.insertStoreInfo(storeInfo); + } + return storeInfo.getId() + ""; + + } + } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 4884c45..40d06bd 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -65,5 +65,5 @@ third-party: retry-times: 3 battery-platform: - appid: 12312321 - access_token: 23213213 \ No newline at end of file + appid: B202507001 + access_token: 6E7C062AC581505438B64574BE7AD887 \ No newline at end of file diff --git a/src/main/resources/mapper/BaseUserMapper.xml b/src/main/resources/mapper/BaseUserMapper.xml new file mode 100644 index 0000000..6b734b1 --- /dev/null +++ b/src/main/resources/mapper/BaseUserMapper.xml @@ -0,0 +1,119 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id, user_name, avatar_url, phone_number, role_id, is_store, nick_name,id_no + + + + + + + INSERT INTO zc_base_user + + user_name, + avatar_url, + password, + phone_number, + role_id, + is_store, + nick_name, + wechat_openid, + operator_id, + store_id, + alipay_userid, + authed, + id_no, + real_name, + front_photo, + back_photo, + del_flag, + create_time, + update_time, + + + #{userName}, + #{avatarUrl}, + #{password}, + #{phoneNumber}, + #{roleId}, + #{isStore}, + #{nickName}, + #{wechatOpenid}, + #{operatorId}, + #{storeId}, + #{alipayUserid}, + #{authed}, + #{idNo}, + #{realName}, + #{frontPhoto}, + #{backPhoto}, + #{delFlag}, + NOW(), + NOW(), + + + + + + + SELECT + id + from zc_base_user + where phone_number = #{phoneNumber} + + UPDATE zc_base_user + + user_name = #{userName}, + avatar_url = #{avatarUrl}, + password = #{password}, + role_id = #{roleId}, + is_store = #{isStore}, + nick_name = #{nickName}, + wechat_openid = #{wechatOpenid}, + operator_id = #{operatorId}, + store_id = #{storeId}, + alipay_userid = #{alipayUserid}, + authed = #{authed}, + id_no = #{idNo}, + real_name = #{realName}, + front_photo = #{frontPhoto}, + back_photo = #{backPhoto}, + del_flag = #{delFlag}, + update_time = NOW(), + + WHERE phone_number = #{phoneNumber} + + + diff --git a/src/main/resources/mapper/BatteryMeal.xml b/src/main/resources/mapper/BatteryMeal.xml index df2cfd8..e99467e 100644 --- a/src/main/resources/mapper/BatteryMeal.xml +++ b/src/main/resources/mapper/BatteryMeal.xml @@ -2,7 +2,7 @@ - + insert into zc_rent_battey_rule title, @@ -38,7 +38,7 @@ - + update zc_rent_battey_rule title = #{title}, diff --git a/src/main/resources/mapper/CompanyInfoMapper.xml b/src/main/resources/mapper/CompanyInfoMapper.xml new file mode 100644 index 0000000..8674d34 --- /dev/null +++ b/src/main/resources/mapper/CompanyInfoMapper.xml @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + b_op_id, company_name, contact_name, phone, address, citys, is_delete + + + + + + + + + + + + + + + SELECT + id + from zc_company + where phone = #{phone} + + UPDATE zc_company + + + company_name = #{companyName}, + + + contact_name = #{contactName}, + + + address = #{address}, + + + citys = #{citys}, + + + is_delete = #{isDelete}, + + + b_op_id = #{bOpId}, + + phone = #{phone} + + WHERE phone = #{phone} + + + + + + + SELECT + id + from zc_company + where phone = #{phone} + + UPDATE zc_company + + + company_name = #{companyName}, + + + contact_name = #{contactName}, + + + address = #{address}, + + + citys = #{citys}, + + + is_delete = #{isDelete}, + + + b_op_id = #{bOpId}, + + phone = #{phone} + + WHERE b_op_id = #{bOpId} + + + + + INSERT INTO zc_company ( + b_op_id, + company_name, + contact_name, + phone, + address, + citys, + is_delete, + is_add_rules, + sharing_ratio, + wechat_receiving_account, + wechat_key, + ali_receiving_account, + ali_key + ) VALUES ( + #{bOpId}, + #{companyName}, + #{contactName}, + #{phone}, + #{address}, + #{citys}, + #{isDelete}, + 0,0,0,0,0,0 + ) + + + diff --git a/src/main/resources/mapper/CompanyStoreMapper.xml b/src/main/resources/mapper/CompanyStoreMapper.xml index 4d8b555..c76b566 100644 --- a/src/main/resources/mapper/CompanyStoreMapper.xml +++ b/src/main/resources/mapper/CompanyStoreMapper.xml @@ -2,6 +2,171 @@ + + + + + + + + + + + + + + + + + + + + + bp_store_id, name, contact_person, phone, province_id, city_id, area_id, address, image, latitude, longitude, del_flag + + + + + + + + + + + SELECT + id + from zc_company_store + where name = #{name} + + UPDATE zc_company_store + + + contact_person = #{contactName}, + + + phone = #{phone}, + + + province_id = #{province}, + + + city_id = #{city}, + + + area_id = #{area}, + + + address = #{address}, + + + image = #{image}, + + + latitude = #{latitude}, + + + longitude = #{longitude}, + + + del_flag = #{isDelete}, + + + bp_store_id = #{bpStoreId}, + + + WHERE name = #{name} + + + + + + SELECT + id + from zc_company_store + where bp_store_id = #{bpStoreId} + + UPDATE zc_company_store + + + name = #{name}, + + + contact_person = #{contactName}, + + + phone = #{phone}, + + + province_id = #{province}, + + + city_id = #{city}, + + + area_id = #{area}, + + + address = #{address}, + + + image = #{image}, + + + latitude = #{latitude}, + + + longitude = #{longitude}, + + + del_flag = #{isDelete}, + + + WHERE bp_store_id = #{bpStoreId} + + + + + INSERT INTO zc_company_store ( + name, + contact_person, + phone, + province_id, + city_id, + area_id, + address, + image, + latitude, + longitude, + del_flag, + bp_store_id + ) VALUES ( + #{name}, + #{contactName}, + #{phone}, + #{province}, + #{city}, + #{area}, + #{address}, + #{image}, + #{latitude}, + #{longitude}, + #{isDelete}, + #{bpStoreId} + ) + + update zc_company_store set bp_store_id = #{bpStoreId} where id =#{cId} diff --git a/src/main/resources/mapper/UserStoreMapper.xml b/src/main/resources/mapper/UserStoreMapper.xml new file mode 100644 index 0000000..24a404b --- /dev/null +++ b/src/main/resources/mapper/UserStoreMapper.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + id, user_id, operator_id, store_id, del_flag, create_by, create_time, update_by, update_time + + + + + + + + UPDATE zc_base_user_store + + operator_id = #{operatorId}, + store_id = #{storeId}, + del_flag = #{delFlag}, + create_by = #{createBy}, + update_by = #{updateBy}, + update_time = NOW(), + + WHERE user_id = #{userId} + + + + + INSERT INTO zc_base_user_store( + user_id, + operator_id, + store_id, + del_flag, + create_by, + create_time, + update_by, + update_time + ) VALUES ( + #{userId}, + #{operatorId}, + #{storeId}, + #{delFlag}, + #{createBy}, + NOW(), + #{updateBy}, + NOW() + ) + +