| @@ -41,6 +41,7 @@ public class TenantInfoImpl implements TenantInfo { | |||
| "wx_level_config", | |||
| "wx_c_user_basic_info", | |||
| "user_basic_info_address", | |||
| "mall_coo_user_info", | |||
| "wx_c_user_basic_child", | |||
| "wx_c_user_basic_sign", | |||
| "wx_credit_history", | |||
| @@ -92,6 +93,7 @@ public class TenantInfoImpl implements TenantInfo { | |||
| "wx_weapp_release_status", | |||
| "wx_c_user_basic_info", | |||
| "user_basic_info_address", | |||
| "mall_coo_user_info", | |||
| "wx_c_user_basic_child", | |||
| "wx_c_user_basic_sign", | |||
| "mem_coupon_from_dsp", | |||
| @@ -36,6 +36,7 @@ public class TenantInfoImpl implements TenantInfo { | |||
| "wx_level_config", | |||
| "wx_c_user_basic_info", | |||
| "user_basic_info_address", | |||
| "mall_coo_user_info", | |||
| "wx_c_user_basic_child", | |||
| "wx_c_user_basic_sign", | |||
| "wx_credit_history", | |||
| @@ -63,6 +64,7 @@ public class TenantInfoImpl implements TenantInfo { | |||
| "wx_user_visit", | |||
| "wx_c_user_basic_info", | |||
| "user_basic_info_address", | |||
| "mall_coo_user_info", | |||
| "wx_c_user_basic_child", | |||
| "wx_c_user_basic_sign", | |||
| "wx_c_user_car", | |||
| @@ -9,6 +9,7 @@ import org.springframework.context.annotation.Bean; | |||
| import org.springframework.context.annotation.EnableAspectJAutoProxy; | |||
| import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties; | |||
| import org.springframework.scheduling.annotation.EnableAsync; | |||
| /** | |||
| * @author chenkx | |||
| @@ -17,6 +18,7 @@ import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties | |||
| @SpringBootApplication | |||
| @MapperScan(basePackages = {"com.iformall.mapper"}) | |||
| @EnableEncryptableProperties | |||
| @EnableAsync | |||
| @EnableRocketMQ | |||
| @EnableAspectJAutoProxy(exposeProxy = true) | |||
| public class CApplication { | |||
| @@ -57,6 +57,9 @@ public class WxUserGrantController extends BaseController { | |||
| @Autowired | |||
| private WxCUserBasicInfoService wxCUserBasicInfoService; | |||
| @Autowired | |||
| private MallCooUserInfoService mallCooUserInfoService; | |||
| @Autowired | |||
| private WxCUserCarService wxCUserCarService; | |||
| @@ -692,6 +695,10 @@ public class WxUserGrantController extends BaseController { | |||
| record.setChildrenList(wxCUserBasicInfo.getChildrenList()); | |||
| record.setUpdChild(true); | |||
| wxCUserBasicInfoService.update(record); | |||
| //推送猫酷 | |||
| mallCooUserInfoService.pullByMobile(tenantEntity, record); | |||
| wxScoreRulesService.addScore(tenantEntity,EnumScoreType.COMPLETE_INFO, record); | |||
| //增加积分 | |||
| WxCreditHistory wxCreditHistory = new WxCreditHistory(); | |||
| @@ -36,6 +36,7 @@ public class TenantInfoImpl implements TenantInfo { | |||
| "wx_level_config", | |||
| "wx_c_user_basic_info", | |||
| "user_basic_info_address", | |||
| "mall_coo_user_info", | |||
| "wx_c_user_basic_child", | |||
| "wx_c_user_basic_sign", | |||
| "wx_credit_history", | |||
| @@ -68,6 +69,7 @@ public class TenantInfoImpl implements TenantInfo { | |||
| "wx_user_visit", | |||
| "wx_c_user_basic_info", | |||
| "user_basic_info_address", | |||
| "mall_coo_user_info", | |||
| "wx_c_user_basic_child", | |||
| "wx_c_user_basic_sign", | |||
| "wx_c_user_car", | |||
| @@ -36,6 +36,7 @@ public class TenantInfoImpl implements TenantInfo { | |||
| "wx_level_config", | |||
| "wx_c_user_basic_info", | |||
| "user_basic_info_address", | |||
| "mall_coo_user_info", | |||
| "wx_c_user_basic_child", | |||
| "wx_c_user_basic_sign", | |||
| "wx_credit_history", | |||
| @@ -68,6 +69,7 @@ public class TenantInfoImpl implements TenantInfo { | |||
| "wx_user_visit", | |||
| "wx_c_user_basic_info", | |||
| "user_basic_info_address", | |||
| "mall_coo_user_info", | |||
| "wx_c_user_basic_child", | |||
| "wx_c_user_basic_sign", | |||
| "wx_c_user_car", | |||
| @@ -96,6 +96,13 @@ public class BaseMyBatisConfiguration { | |||
| basicInfoAddressSharding.setRule(EnumShardingRule.HASH.getCode()); | |||
| shardingList.add(basicInfoAddressSharding); | |||
| ShardingSphere mallCooUserInfoSharding = new ShardingSphere(); | |||
| mallCooUserInfoSharding.setColumn("final_tenant_id"); | |||
| mallCooUserInfoSharding.setTableName("mall_coo_user_info"); | |||
| mallCooUserInfoSharding.setCount(100); | |||
| mallCooUserInfoSharding.setRule(EnumShardingRule.HASH.getCode()); | |||
| shardingList.add(mallCooUserInfoSharding); | |||
| ShardingSphere basicSignSharding = new ShardingSphere(); | |||
| basicSignSharding.setColumn("tenant_id"); | |||
| basicSignSharding.setTableName("wx_c_user_basic_sign"); | |||
| @@ -0,0 +1,80 @@ | |||
| package com.iformall.domain.po; | |||
| import com.baomidou.mybatisplus.annotation.TableField; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import com.fasterxml.jackson.annotation.JsonIgnore; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.base.TenantEntityWithoutFinalTenantId; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import lombok.ToString; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import java.util.Date; | |||
| @TableName(value = "mall_coo_user_info") | |||
| @Data | |||
| @ToString(callSuper = true) | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class MallCooUserInfo extends TenantEntityWithoutFinalTenantId { | |||
| protected Long id; | |||
| @io.swagger.annotations.ApiModelProperty(value="如果是集团版的,存集团版的tenantId,如果是商场,则存商场",name="sex") | |||
| private String finalTenantId; | |||
| @JsonIgnore | |||
| @TableField(exist = false) | |||
| protected String shardFinalTableSuffix; | |||
| public String getShardFinalTableSuffix(){ | |||
| if(StringUtils.isNotBlank(finalTenantId)){ | |||
| shardFinalTableSuffix = "_" + Integer.parseInt(finalTenantId)%100; | |||
| } | |||
| return shardFinalTableSuffix; | |||
| } | |||
| @io.swagger.annotations.ApiModelProperty(value="猫酷用户ID",name="openUserId") | |||
| private String openUserId; | |||
| @io.swagger.annotations.ApiModelProperty(value="手机号",name="phone") | |||
| private String phone; | |||
| @io.swagger.annotations.ApiModelProperty(value="用户姓名",name="userName") | |||
| private String userName; | |||
| @io.swagger.annotations.ApiModelProperty(value="性别:0:保密 1.男 2.女",name="sex") | |||
| private Integer gender; | |||
| @io.swagger.annotations.ApiModelProperty(value="出生日期",name="birthdate") | |||
| private Date birthdate; | |||
| @io.swagger.annotations.ApiModelProperty(value="地址",name="address") | |||
| private String address; | |||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | |||
| private Date updateDate; | |||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | |||
| private Date createDate; | |||
| public void undateFinalTenantId(TenantEntity tenantEntity){ | |||
| // setTenantId(tenantEntity.getTenantId()); | |||
| // setParentTenantId(tenantEntity.getParentTenantId()); | |||
| setFinalTenantId(tenantEntity.getTenantId()); | |||
| if(StringUtils.isNotBlank(tenantEntity.getParentTenantId())){ | |||
| setFinalTenantId(tenantEntity.getParentTenantId()); | |||
| } | |||
| if(!tenantEntity.getTenantId().equals(getFinalTenantId())){ | |||
| setTenantId(tenantEntity.getTenantId()); | |||
| } | |||
| } | |||
| @TableField(exist = false) | |||
| private Date startTime; | |||
| @TableField(exist = false) | |||
| private Date endTime; | |||
| } | |||
| @@ -8,6 +8,7 @@ public enum EnumThirdPartyConfigType { | |||
| WEIXIN(1, "微信"), | |||
| GOOAGOO(5, "数衍科技"), | |||
| MALLCOO(2, "猫酷"), | |||
| ; | |||
| public static EnumThirdPartyConfigType getEnum(Integer code) { | |||
| @@ -0,0 +1,167 @@ | |||
| package com.iformall.mallcoo; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.domain.po.WxThirdPartyApi; | |||
| import com.iformall.domain.po.WxThirdPartyConfig; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.utils.DateUtils; | |||
| import com.iformall.utils.HttpUtil; | |||
| import lombok.extern.slf4j.Slf4j; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import java.nio.charset.StandardCharsets; | |||
| import java.security.MessageDigest; | |||
| import java.security.NoSuchAlgorithmException; | |||
| import java.util.*; | |||
| /** | |||
| * 猫酷开放平台 | |||
| * https://docs.mallcoo.cn/open/Guide.html | |||
| * @author | |||
| */ | |||
| @Slf4j | |||
| public class MallcooHelper { | |||
| private static String getSign(WxThirdPartyConfig config ,String dateStr,String dataJson) { | |||
| String encryptString = "{publicKey:" + config.getAppKey() + | |||
| ",timeStamp:" + dateStr + | |||
| ",data:" + dataJson + | |||
| ",privateKey:" + config.getSignKey() + "}"; | |||
| log.info("加密字符串"+encryptString); | |||
| return md5FromStr(encryptString).toUpperCase().substring(8,24); | |||
| } | |||
| private static String md5FromStr(String inStr) { | |||
| MessageDigest md5; | |||
| try { | |||
| md5 = MessageDigest.getInstance("MD5"); | |||
| } catch (NoSuchAlgorithmException e) { | |||
| e.printStackTrace(); | |||
| return ""; | |||
| } | |||
| byte[] byteArray = inStr.getBytes(StandardCharsets.UTF_8); | |||
| byte[] md5Bytes = md5.digest(byteArray); | |||
| StringBuilder hexValue = new StringBuilder(); | |||
| for (byte md5Byte : md5Bytes) { | |||
| int val = ((int) md5Byte) & 0xff; | |||
| if (val < 16) { | |||
| hexValue.append("0"); | |||
| } | |||
| hexValue.append(Integer.toHexString(val)); | |||
| } | |||
| return hexValue.toString(); | |||
| } | |||
| private static String doPost(WxThirdPartyConfig config, String url, Map<String, Object> params) { | |||
| Map<String,String> headMap = new HashMap<>(); | |||
| headMap.put("AppID",config.getAppId()); | |||
| headMap.put("PublicKey",config.getAppKey()); | |||
| String dateStr = DateUtils.date2String(new Date(), "yyyyMMddHHmmss"); | |||
| headMap.put("TimeStamp",dateStr); | |||
| String dataJson = JSON.toJSONString(params); | |||
| String sign = getSign(config, dateStr, dataJson); | |||
| headMap.put("Sign",sign); | |||
| return HttpUtil.doPost(url,headMap, dataJson); | |||
| } | |||
| //根据手机号更新会员信息 | |||
| public static boolean updateByMobile(WxThirdPartyConfig config,String mobile,McUserInfo info) { | |||
| String url = "https://openapi10.mallcoo.cn/User/AdvancedInfo/v1/Update/ByMobile/"; | |||
| Map<String,Object> map = new HashMap<>(); | |||
| map.put("Mobile",mobile); | |||
| map.put("UserInfo",JSON.toJSONString(info.toRequestMap())); | |||
| String response = doPost(config,url, map); | |||
| log.info("根据手机号更新会员信息 request:"+JSON.toJSONString(map) | |||
| +" response:"+response); | |||
| JSONObject jsonObject = JSON.parseObject(response); | |||
| Integer code = jsonObject.getInteger("Code"); | |||
| if (null != code && code.intValue() == 1 ) { | |||
| return true; | |||
| }else{ | |||
| String message = jsonObject.getString("Message"); | |||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),message); | |||
| } | |||
| } | |||
| //根据手机号获取会员信息 | |||
| public static McUserInfo getByMobile(WxThirdPartyConfig config,String mobile) { | |||
| String url = "https://openapi10.mallcoo.cn/User/AdvancedInfo/v1/Get/ByMobile/"; | |||
| Map<String,Object> map = new HashMap<>(); | |||
| map.put("Mobile",mobile); | |||
| String response = doPost(config,url, map); | |||
| log.info("根据手机号更新会员信息 request:"+JSON.toJSONString(map) | |||
| +" response:"+response); | |||
| JSONObject jsonObject = JSON.parseObject(response); | |||
| Integer code = jsonObject.getInteger("Code"); | |||
| if (null != code && code.intValue() == 1 ) { | |||
| JSONObject data = jsonObject.getJSONObject("Data"); | |||
| McUserInfo info = new McUserInfo(); | |||
| return info; | |||
| }else{ | |||
| String message = jsonObject.getString("Message"); | |||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),message); | |||
| } | |||
| } | |||
| //手机号直接开通会员卡 | |||
| public static String openByMobile(WxThirdPartyConfig config,String mobile,String dataSource) { | |||
| String url = "https://openapi10.mallcoo.cn/User/MallCard/v1/Open/ByMobile/"; | |||
| Map<String,Object> map = new HashMap<>(); | |||
| map.put("Mobile",mobile); | |||
| if(StringUtils.isNotBlank(dataSource)){ | |||
| map.put("DataSource",dataSource); | |||
| } | |||
| String response = doPost(config,url, map); | |||
| log.info("手机号直接开通会员卡 request:"+JSON.toJSONString(map) | |||
| +" response:"+response); | |||
| JSONObject jsonObject = JSON.parseObject(response); | |||
| Integer code = jsonObject.getInteger("Code"); | |||
| if (null != code && code.intValue() == 1 ) { | |||
| JSONObject data = jsonObject.getJSONObject("Data"); | |||
| String openUserID = data.getString("OpenUserID"); | |||
| return openUserID; | |||
| }else if(null != code && code.intValue() == 307 ){ | |||
| JSONObject data = jsonObject.getJSONObject("Data"); | |||
| String openUserID = data.getString("OpenUserID"); | |||
| return openUserID; | |||
| }else{ | |||
| String message = jsonObject.getString("Message"); | |||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),message); | |||
| } | |||
| } | |||
| public static void main(String[] args) { | |||
| WxThirdPartyConfig config = new WxThirdPartyConfig(); | |||
| config.setAppId("625fa8b81c415a1114eab6d7"); | |||
| config.setAppKey("JV7kP9"); | |||
| config.setSignKey("12b51d39c3c1762d"); | |||
| String phone = "18872592633"; | |||
| // String s = openByMobile(config, phone, null); | |||
| // System.out.println("-----"+s); | |||
| // McUserInfo info = new McUserInfo(); | |||
| // info.setUserName("周大姑娘"); | |||
| // info.setGender(2); | |||
| // info.setAge(25); | |||
| // info.setAddress("湖北武汉"); | |||
| // info.setBirthday(DateUtils.stringToDate("1998-01-10")); | |||
| // boolean b = updateByMobile(config, phone, info); | |||
| // System.out.println("-----"+b); | |||
| McUserInfo byMobile = getByMobile(config, phone); | |||
| System.out.println("-----"+byMobile.toString()); | |||
| } | |||
| } | |||
| @@ -0,0 +1,51 @@ | |||
| package com.iformall.mallcoo; | |||
| import com.iformall.utils.DateUtils; | |||
| import lombok.Data; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import java.util.Date; | |||
| import java.util.HashMap; | |||
| import java.util.Map; | |||
| @Data | |||
| public class McUserInfo { | |||
| private String userName;//姓名 | |||
| private Integer gender;//性别 1: 男2:女0: 未知 | |||
| private Integer age;//年龄 | |||
| private Date birthday;//出生日期 | |||
| private String address;//详细地址 | |||
| public boolean canToRequest(){ | |||
| if(StringUtils.isBlank(userName) | |||
| && gender == null | |||
| && age == null | |||
| && birthday == null | |||
| && StringUtils.isNotBlank(address)){ | |||
| return false; | |||
| } | |||
| return true; | |||
| } | |||
| public Map toRequestMap() { | |||
| Map map = new HashMap(); | |||
| if(StringUtils.isNotBlank(userName)){ | |||
| map.put("UserName", userName); | |||
| } | |||
| if(gender != null){ | |||
| map.put("Gender",gender); | |||
| } | |||
| if(age != null){ | |||
| map.put("Age",age); | |||
| } | |||
| if(birthday != null){ | |||
| String birthdayStr = DateUtils.date2String(birthday, "yyyy-MM-dd'T'HH:mm:ss.SSSZ"); | |||
| map.put("Birthday",birthdayStr); | |||
| } | |||
| if(StringUtils.isNotBlank(address)){ | |||
| map.put("Address",address); | |||
| } | |||
| return map; | |||
| } | |||
| } | |||
| @@ -0,0 +1,17 @@ | |||
| package com.iformall.mapper; | |||
| import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.po.MallCooUserInfo; | |||
| import org.apache.ibatis.annotations.Param; | |||
| import java.util.List; | |||
| public interface MallCooUserInfoMapper extends CommonMapper<MallCooUserInfo, String> { | |||
| List<MallCooUserInfo> findList(MallCooUserInfo mallCooUserInfo); | |||
| MallCooUserInfo selectById(@Param("id")Long id,@Param("finalTenantId")String finalTenantId); | |||
| } | |||
| @@ -0,0 +1,30 @@ | |||
| package com.iformall.service; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| public interface MallCooUserInfoService { | |||
| /** | |||
| * 根据实体查询分页列表 | |||
| * | |||
| * @param record | |||
| * @param pageIndex | |||
| * @param pageSize | |||
| * @return | |||
| */ | |||
| PageInfo<MallCooUserInfo> listAsPage(MallCooUserInfo record, Integer pageIndex, Integer pageSize); | |||
| /** | |||
| * 根据Id获得实体 | |||
| * | |||
| * @param id | |||
| * @return | |||
| */ | |||
| MallCooUserInfo getById(Long id,String finalTenantId); | |||
| void pullByMobile(TenantEntity tenantEntity, WxCUserBasicInfo basicInfo); | |||
| } | |||
| @@ -34,6 +34,9 @@ public class BasicCUserService { | |||
| @Autowired | |||
| private WxCUserBasicInfoService wxCUserBasicInfoService; | |||
| @Autowired | |||
| private MallCooUserInfoService mallCooUserInfoService; | |||
| @Autowired | |||
| private WxCUserTagsService wxCUserTagsService; | |||
| @@ -156,6 +159,9 @@ public class BasicCUserService { | |||
| // 外部注券 | |||
| memCouponFromDspService.couponOrderFromDsp(tenantEntity, userPhone); | |||
| //推送猫酷 | |||
| mallCooUserInfoService.pullByMobile(tenantEntity, basicInfo); | |||
| return basicInfo.getId(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,111 @@ | |||
| package com.iformall.service.impl; | |||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.enums.EnumThirdPartyConfigType; | |||
| import com.iformall.mallcoo.MallcooHelper; | |||
| import com.iformall.mallcoo.McUserInfo; | |||
| import com.iformall.mapper.*; | |||
| import com.iformall.service.*; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.scheduling.annotation.Async; | |||
| import org.springframework.stereotype.Service; | |||
| import java.util.Date; | |||
| @Service | |||
| public class MallCooUserInfoServiceImpl implements MallCooUserInfoService { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| MallCooUserInfoMapper mallCooUserInfoMapper; | |||
| @Autowired | |||
| WxCUserBasicInfoMapper wxCUserBasicInfoMapper; | |||
| @Autowired | |||
| WxThirdPartyConfigMapper wxThirdPartyConfigMapper; | |||
| @Override | |||
| public PageInfo<MallCooUserInfo> listAsPage(MallCooUserInfo record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> mallCooUserInfoMapper.findList(record)); | |||
| } | |||
| @Override | |||
| public MallCooUserInfo getById(Long id,String finalTenantId) { | |||
| return mallCooUserInfoMapper.selectById(id,finalTenantId); | |||
| } | |||
| @Async | |||
| @Override | |||
| public void pullByMobile(TenantEntity tenantEntity, WxCUserBasicInfo basicInfo) { | |||
| try{ | |||
| WxThirdPartyConfig config = getThirdPartyConfig(tenantEntity); | |||
| if(config == null){ | |||
| logger.error("未找到猫酷配置信息"); | |||
| return; | |||
| } | |||
| if(StringUtils.isBlank(basicInfo.getPhone())){ | |||
| basicInfo = wxCUserBasicInfoMapper.selectById(basicInfo.getId(),basicInfo.getFinalTenantId()); | |||
| } | |||
| MallCooUserInfo mallCooUserInfo = this.getById(basicInfo.getId(), basicInfo.getFinalTenantId()); | |||
| if(mallCooUserInfo == null){ | |||
| String openUserID = MallcooHelper.openByMobile(config, basicInfo.getPhone(), null); | |||
| if(StringUtils.isNotBlank(openUserID)){ | |||
| Date now = new Date(); | |||
| mallCooUserInfo = new MallCooUserInfo(); | |||
| mallCooUserInfo.setId(basicInfo.getId()); | |||
| mallCooUserInfo.setFinalTenantId(basicInfo.getFinalTenantId()); | |||
| mallCooUserInfo.setOpenUserId(openUserID); | |||
| mallCooUserInfo.setPhone(basicInfo.getPhone()); | |||
| mallCooUserInfo.setCreateDate(now); | |||
| mallCooUserInfo.setUpdateDate(now); | |||
| mallCooUserInfoMapper.insert(mallCooUserInfo); | |||
| } | |||
| } | |||
| if(!basicInfo.getPhone().equals(mallCooUserInfo.getPhone())){ | |||
| logger.error("更换过手机号,咱未实现更改手机号同步"); | |||
| return; | |||
| } | |||
| McUserInfo info = new McUserInfo(); | |||
| info.setUserName(basicInfo.getName()); | |||
| info.setBirthday(basicInfo.getBirthdate()); | |||
| info.setGender(basicInfo.getSex()); | |||
| info.setAddress(basicInfo.getAddress()); | |||
| if(info.canToRequest()){ | |||
| boolean flag = MallcooHelper.updateByMobile(config, basicInfo.getPhone(), info); | |||
| if(flag){ | |||
| mallCooUserInfo.setUserName(basicInfo.getName()); | |||
| mallCooUserInfo.setBirthdate(basicInfo.getBirthdate()); | |||
| mallCooUserInfo.setGender(basicInfo.getSex()); | |||
| mallCooUserInfo.setAddress(basicInfo.getAddress()); | |||
| mallCooUserInfo.setUpdateDate(new Date()); | |||
| mallCooUserInfoMapper.updateById(mallCooUserInfo); | |||
| } | |||
| } | |||
| }catch(Exception e){ | |||
| logger.error("同步猫酷会员error"+e.getMessage()); | |||
| } | |||
| } | |||
| private WxThirdPartyConfig getThirdPartyConfig(TenantEntity tenantEntity){ | |||
| WxThirdPartyConfig configQ = new WxThirdPartyConfig(); | |||
| configQ.updateTenantInfo(tenantEntity); | |||
| configQ.setType(EnumThirdPartyConfigType.MALLCOO.getCode()); | |||
| WxThirdPartyConfig config = wxThirdPartyConfigMapper.selectOne(new QueryWrapper<>(configQ)); | |||
| return config; | |||
| } | |||
| } | |||
| @@ -516,10 +516,10 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService { | |||
| if(!EnumCouponType.getSpuSyncType().contains(coupon.getType())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"卷类型不支持同步poi"); | |||
| } | |||
| List<TtMerchantPoi> list = new ArrayList<>(); | |||
| TtMerchantPoi merchantPoi = ttMerchantPoiMapper.selectById(Long.parseLong(tenantInfo.getTenantId())); | |||
| // TtMerchantPoi merchantPoi = ttMerchantPoiMapper.selectById(Long.parseLong("1038")); | |||
| list.add(merchantPoi); | |||
| // List<TtMerchantPoi> list = new ArrayList<>(); | |||
| // TtMerchantPoi merchantPoi = ttMerchantPoiMapper.selectById(Long.parseLong(tenantInfo.getTenantId())); | |||
| //// TtMerchantPoi merchantPoi = ttMerchantPoiMapper.selectById(Long.parseLong("1038")); | |||
| // list.add(merchantPoi); | |||
| List<Long> merchantIds = wxCouponMerchantMapper.findMerchantIdListByProduct(coupon.getId(), tenantInfo.getTenantId()); | |||
| if(merchantIds == null || merchantIds.size() == 0 ){ | |||
| @@ -532,11 +532,12 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService { | |||
| poi.setMatchStatus(EnumSupplierMathStatus.match_success.getCode()); | |||
| poi.setSyncStatus(EnumSupplierSyncStatus.sync_success.getCode()); | |||
| List<TtMerchantPoi> poiList = ttMerchantPoiMapper.findList(poi); | |||
| if(poiList != null && poiList.size() > 0){ | |||
| list.addAll(poiList); | |||
| if(poiList != null && merchantIds.size() == poiList.size()){ | |||
| return new ResultData(poiList); | |||
| }else{ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该商品店铺与poi门店不匹配"); | |||
| } | |||
| return new ResultData(list); | |||
| } | |||
| private void updateWebAccessToken(WxAppinfo appinfo, TtWebService ttWebService) { | |||
| @@ -575,6 +576,7 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService { | |||
| if(!EnumCouponType.getSpuSyncType().contains(coupon.getType())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"卷类型不支持同步poi"); | |||
| } | |||
| TtMerchantPoi poi = new TtMerchantPoi(); | |||
| poi.updateTenantInfo(tenantInfo); | |||
| poi.setIds(merchantIds); | |||
| @@ -0,0 +1,82 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||
| <mapper namespace="com.iformall.mapper.MallCooUserInfoMapper"> | |||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.MallCooUserInfo"> | |||
| <id column="id" jdbcType="BIGINT" property="id"/> | |||
| <result column="open_user_id" jdbcType="VARCHAR" property="openUserId"/> | |||
| <result column="phone" jdbcType="VARCHAR" property="phone"/> | |||
| <result column="birthdate" jdbcType="TIMESTAMP" property="birthdate"/> | |||
| <result column="gender" jdbcType="INTEGER" property="gender"/> | |||
| <result column="address" jdbcType="VARCHAR" property="address"/> | |||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/> | |||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/> | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | |||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/> | |||
| <result column="final_tenant_id" jdbcType="VARCHAR" property="finalTenantId"/> | |||
| <result column="user_name" jdbcType="VARCHAR" property="userName"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`open_user_id`,`phone`,`birthdate`,`gender`, | |||
| `address`,`create_date`,`update_date`, | |||
| `final_tenant_id`,`tenant_id`,`parent_tenant_id`,`user_name` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| where `final_tenant_id` = #{finalTenantId} | |||
| <if test=" null != id "> | |||
| and `id` = #{id} | |||
| </if> | |||
| <if test=" null != phone "> | |||
| and `phone` like concat('%', #{phone},'%') | |||
| </if> | |||
| <if test=" null != birthdate "> | |||
| and `birthdate` = #{birthdate} | |||
| </if> | |||
| <if test=" null != gender "> | |||
| and `gender` = #{gender} | |||
| </if> | |||
| <if test=" null != address "> | |||
| and `address` like concat('%', #{address},'%') | |||
| </if> | |||
| <if test=" null != userName "> | |||
| and `user_name` like concat('%', #{userName},'%') | |||
| </if> | |||
| <if test=" null != startTime and null != endTime"> | |||
| and `create_date` between #{startTime} and #{endTime} | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| #{idItem} | |||
| </foreach> | |||
| </if> | |||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | |||
| </sql> | |||
| <select id="selectById" parameterType="java.util.HashMap" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns"/> | |||
| from mall_coo_user_info | |||
| where id =#{id} | |||
| and final_tenant_id = #{finalTenantId} | |||
| </select> | |||
| <select id="findList" parameterType="com.iformall.domain.po.MallCooUserInfo" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumns"/> | |||
| from mall_coo_user_info | |||
| <include refid="dynamicWhereConditions"/> | |||
| </select> | |||
| </mapper> | |||