From 1df49326bf46add565d15d83c37a26fe47c1d5e9 Mon Sep 17 00:00:00 2001 From: xhxuc Date: Thu, 4 Jun 2020 13:55:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=9C=BA=E6=95=B0=E6=8D=AEinit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../basic/WxProjectConfigController.java | 38 ++ .../java/com/iformall/domain/po/WxMall.java | 3 + .../iformall/domain/po/WxMallBuilding.java | 2 + .../iformall/domain/po/WxProjectConfig.java | 96 ++++ .../mapper/WxProjectConfigMapper.java | 10 + .../service/WxProjectConfigService.java | 13 + .../impl/WxProjectConfigServiceImpl.java | 427 ++++++++++++++++++ .../com/iformall/utils/PasswordHelper.java | 34 ++ .../mapper/WxProjectConfigMapper.xml | 5 + 9 files changed, 628 insertions(+) create mode 100644 mallinkAdmin/src/main/java/com/iformall/controller/basic/WxProjectConfigController.java create mode 100644 mallinkService/src/main/java/com/iformall/domain/po/WxProjectConfig.java create mode 100644 mallinkService/src/main/java/com/iformall/mapper/WxProjectConfigMapper.java create mode 100644 mallinkService/src/main/java/com/iformall/service/WxProjectConfigService.java create mode 100644 mallinkService/src/main/java/com/iformall/service/impl/WxProjectConfigServiceImpl.java create mode 100644 mallinkService/src/main/java/com/iformall/utils/PasswordHelper.java create mode 100644 mallinkService/src/main/resources/mapper/WxProjectConfigMapper.xml diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/basic/WxProjectConfigController.java b/mallinkAdmin/src/main/java/com/iformall/controller/basic/WxProjectConfigController.java new file mode 100644 index 000000000..dc0633aab --- /dev/null +++ b/mallinkAdmin/src/main/java/com/iformall/controller/basic/WxProjectConfigController.java @@ -0,0 +1,38 @@ +package com.iformall.controller.basic; + +import com.iformall.annotation.SystemControllerLog; +import com.iformall.common.ErrorCode; +import com.iformall.common.ResultData; +import com.iformall.controller.base.BaseController; +import com.iformall.service.WxProjectConfigService; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequestMapping("wxProjectConfig") +public class WxProjectConfigController extends BaseController { + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Autowired + private WxProjectConfigService wxProjectConfigService; + + @ApiOperation("添加商场基础数据") + @GetMapping(value = "/init/{id}") + @SystemControllerLog(description = "商场基础数据") + public ResultData init(@PathVariable Long id) { + logger.debug("[" + getIpAddr() + "] WxProjectConfigController::init"); + try { + wxProjectConfigService.initProjectConfig(id); + return new ResultData(); + }catch (Exception e){ + return new ResultData(ErrorCode.SYS_SERVER_ERROR); + } + + + } + + +} diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxMall.java b/mallinkService/src/main/java/com/iformall/domain/po/WxMall.java index 1f05c0a25..37374ea12 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxMall.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxMall.java @@ -1,6 +1,8 @@ package com.iformall.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 com.fasterxml.jackson.annotation.JsonProperty; import com.iformall.domain.po.base.BaseEntity; @@ -17,6 +19,7 @@ import java.util.List; @EqualsAndHashCode(callSuper = true) public class WxMall extends BaseEntity { + @TableId(type= IdType.AUTO) protected Long id; @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxMallBuilding.java b/mallinkService/src/main/java/com/iformall/domain/po/WxMallBuilding.java index d0cb23952..360951029 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxMallBuilding.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxMallBuilding.java @@ -24,6 +24,8 @@ public class WxMallBuilding extends TenantEntity { private Long mallId; @io.swagger.annotations.ApiModelProperty(value="楼座名",name="name") private String name; + @io.swagger.annotations.ApiModelProperty(value="楼座名",name="buildingName") + private String buildingName; @io.swagger.annotations.ApiModelProperty(value="楼层数",name="floorNumber") private Integer floorNumber; @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxProjectConfig.java b/mallinkService/src/main/java/com/iformall/domain/po/WxProjectConfig.java new file mode 100644 index 000000000..4656019fe --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxProjectConfig.java @@ -0,0 +1,96 @@ +package com.iformall.domain.po; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.iformall.domain.po.base.BaseEntity; +import com.iformall.domain.po.base.TenantEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +@TableName(value = "wx_project_config") +@Data +@EqualsAndHashCode(callSuper = true) +public class WxProjectConfig extends BaseEntity { + + protected Long id; + + @io.swagger.annotations.ApiModelProperty(value="商场名",name="name") + private String name; + @io.swagger.annotations.ApiModelProperty(value="国家",name="country") + private String country; + @io.swagger.annotations.ApiModelProperty(value="省",name="province") + private String province; + @io.swagger.annotations.ApiModelProperty(value="城市",name="city") + private String city; + @io.swagger.annotations.ApiModelProperty(value="地址",name="addr") + private String addr; + @io.swagger.annotations.ApiModelProperty(value="总面积",name="totalArea") + private BigDecimal totalArea; + @io.swagger.annotations.ApiModelProperty(value="营业面积",name="operatingArea") + private BigDecimal operatingArea; + @io.swagger.annotations.ApiModelProperty(value="停车场面积",name="parkArea") + private BigDecimal parkArea; + @io.swagger.annotations.ApiModelProperty(value="车位数",name="parkPlaceNumber") + private Integer parkPlaceNumber; + @io.swagger.annotations.ApiModelProperty(value="电话",name="servicePhone") + private String servicePhone; + @io.swagger.annotations.ApiModelProperty(value="商场图标",name="imgUrl") + private String imgUrl; + @io.swagger.annotations.ApiModelProperty(value="商场图标-H",name="imgUrlH") + private String imgUrlH; + + //1(全能版)、2(营销版,除了合同,账单功能),3.速享版(营销版加3个月限制) + @io.swagger.annotations.ApiModelProperty(value="",name="saleType") + private Integer saleType; + + @io.swagger.annotations.ApiModelProperty(value="商场楼座",name="mallBuilding") + private String mallBuilding; + + @io.swagger.annotations.ApiModelProperty(value="微信商户号/特约服务商号",name="mchId") + private String mchId; + @io.swagger.annotations.ApiModelProperty(value="微信服务商号",name="subMchId") + private String subMchId; + @io.swagger.annotations.ApiModelProperty(value="支付密钥",name="apiKey") + private String apiKey; +// @io.swagger.annotations.ApiModelProperty(value="微信回调,支持3种回调,(1.url/pay 2.url/refund3.url/separate)",name="notifyUrl") +// private String notifyUrl; +// @io.swagger.annotations.ApiModelProperty(value="证书本地存放位置",name="certPath") +// private String certPath; + @io.swagger.annotations.ApiModelProperty(value="手续费(万分之几,默认60)",name="rate") + private Integer rate; + @io.swagger.annotations.ApiModelProperty(value="实际手续费(万分之几,默认60)",name="realRate") + private Integer realRate; + + @io.swagger.annotations.ApiModelProperty(value="小程序ID(B端)",name="appIdB") + private String appIdB; + @io.swagger.annotations.ApiModelProperty(value="小程序ID(C端)",name="appIdC") + private String appIdC; + @io.swagger.annotations.ApiModelProperty(value="公众号ID",name="parentAppId") + private String parentAppId; + @io.swagger.annotations.ApiModelProperty(value="小程序名(B端)",name="appNameB") + private String appNameB; + @io.swagger.annotations.ApiModelProperty(value="小程序名(C端)",name="appNameC") + private String appNameC; + @io.swagger.annotations.ApiModelProperty(value="小程序secret(B端)",name="appSecretB") + private String appSecretB; + @io.swagger.annotations.ApiModelProperty(value="小程序secret(C端)",name="appSecretC") + private String appSecretC; + + @io.swagger.annotations.ApiModelProperty(value="A端管理员帐号",name="usernameA") + private String usernameA; + @io.swagger.annotations.ApiModelProperty(value="A端管理员密码",name="password") + private String password; + @io.swagger.annotations.ApiModelProperty(value="A端管理员名称",name="nameA") + private String nameA; + @io.swagger.annotations.ApiModelProperty(value="联系电话",name="phone") + private String phone; + + @io.swagger.annotations.ApiModelProperty(value="销售类型",name="delType") + private Integer delType; + +} diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxProjectConfigMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxProjectConfigMapper.java new file mode 100644 index 000000000..ca8b44c76 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/mapper/WxProjectConfigMapper.java @@ -0,0 +1,10 @@ +package com.iformall.mapper; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.iformall.domain.po.WxProjectConfig; + +public interface WxProjectConfigMapper extends BaseMapper { + + +} diff --git a/mallinkService/src/main/java/com/iformall/service/WxProjectConfigService.java b/mallinkService/src/main/java/com/iformall/service/WxProjectConfigService.java new file mode 100644 index 000000000..f1fa8b340 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/service/WxProjectConfigService.java @@ -0,0 +1,13 @@ +package com.iformall.service; + + +public interface WxProjectConfigService { + + /** + * 根据wx_project_config数据生成初始化商户数据 + * + * @param id + */ + void initProjectConfig(Long id); + +} diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxProjectConfigServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxProjectConfigServiceImpl.java new file mode 100644 index 000000000..88a93405c --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxProjectConfigServiceImpl.java @@ -0,0 +1,427 @@ +package com.iformall.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.iformall.domain.po.*; +import com.iformall.enums.EnumCouponSendSendType; +import com.iformall.mapper.*; +import com.iformall.service.WxProjectConfigService; +import com.iformall.utils.PasswordHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; + +@Service +public class WxProjectConfigServiceImpl implements WxProjectConfigService { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Autowired + WxProjectConfigMapper wxProjectConfigMapper; + @Autowired + WxMallMapper wxMallMapper; + @Autowired + WxCouponSendConfigMapper wxCouponSendConfigMapper; + @Autowired + WxMallBuildingMapper wxMallBuildingMapper; + @Autowired + WxMallFloorMapper wxMallFloorMapper; + @Autowired + WxPayAccountMapper wxPayAccountMapper; + @Autowired + WxPayAccountBillMapper wxPayAccountBillMapper; + @Autowired + WxAppinfoMapper wxAppinfoMapper; + @Autowired + WxWeappExtSetMapper wxWeappExtSetMapper; + @Autowired + MallUserInfoMapper mallUserInfoMapper; + @Autowired + MallRoleMapper mallRoleMapper; + @Autowired + MallRolePermissionMapper mallRolePermissionMapper; + @Autowired + MallUserRoleMapper mallUserRoleMapper; + @Autowired + WxMsgConfigMapper wxMsgConfigMapper; + @Autowired + WxParkMapper wxParkMapper; + @Autowired + WxScoreRulesMapper wxScoreRulesMapper; + @Autowired + WxTemplateMsgMapper wxTemplateMsgMapper; + @Autowired + WxWiwideInfoMapper wxWiwideInfoMapper; + @Autowired + WxQuestionMapper wxQuestionMapper; + @Autowired + WxMsgValidationcodeModelMapper wxMsgValidationcodeModelMapper; + @Autowired + WxFlowConfigMapper wxFlowConfigMapper; + + + @Override + @Transactional + public void initProjectConfig(Long id) { + WxProjectConfig wxProjectConfig = wxProjectConfigMapper.selectById(id); + if(wxProjectConfig!=null && wxProjectConfig.getDelType()<10000){ + Date nowTime = new Date(); + // 1. wx_mall 商场 + WxMall wxMall = new WxMall(); + wxMall.setTenantId("-1"); + wxMall.setName(wxProjectConfig.getName()); + wxMall.setGroup(wxProjectConfig.getName());//无用 + wxMall.setCountry(wxProjectConfig.getCountry()); + wxMall.setProvince(wxProjectConfig.getProvince()); + wxMall.setCity(wxProjectConfig.getCity()); + wxMall.setAddr(wxProjectConfig.getAddr()); + wxMall.setTotalArea(wxProjectConfig.getTotalArea()); + wxMall.setOperatingArea(wxProjectConfig.getTotalArea());//无用 + wxMall.setParkArea(wxProjectConfig.getParkArea()); + wxMall.setParkPlaceNumber(wxProjectConfig.getParkPlaceNumber()); + wxMall.setServicePhone(wxProjectConfig.getServicePhone()); + wxMall.setImgUrl(wxProjectConfig.getImgUrl()); + wxMall.setImgUrlH(wxProjectConfig.getImgUrlH()); + String weapNote = "{\"carpage\": {\"desc\": \"分享个停车小程序,希望你喜欢\", \"title\": \"" + + wxProjectConfig.getName() + + "\"}, \"firstpage\": {\"desc\": \"分享个小程序,希望你喜欢\", \"title\": \"" + + wxProjectConfig.getName() + + "\"}}"; + + wxMall.setWeapNote(weapNote); + + //(1(全能版)、2(营销版,除了合同,账单功能),3.速享版(营销版加3个月限制)分别什么意思) + wxMall.setSaleType(wxProjectConfig.getSaleType()); + wxMall.setBusinessHours("[]"); + wxMall.setIntroduction(""); + wxMall.setImg(""); + wxMallMapper.insert(wxMall); + wxMall.setTenantId(wxMall.getId().toString()); + wxMallMapper.updateById(wxMall); + logger.info("wx_mall 商场---------------------init--success"); + + // 2. wx_coupon_send_config + WxCouponSendConfig wxCouponSendConfig = new WxCouponSendConfig(); + wxCouponSendConfig.setTenantId(wxMall.getTenantId()); + wxCouponSendConfig.setValue(0);//默认停用 + wxCouponSendConfig.setCreateTime(nowTime); + wxCouponSendConfig.setUpdateTime(nowTime); + for (EnumCouponSendSendType value : EnumCouponSendSendType.values()) { + wxCouponSendConfig.setId(null); + if (value.getCode() > 1) { + wxCouponSendConfig.setSendType(value.getCode()); + wxCouponSendConfig.setRemark( value.getMessage() + "开关"); + wxCouponSendConfigMapper.insert(wxCouponSendConfig); + } + } + logger.info("wx_coupon_send_config ---------------------init--success"); + + // 3. wx_mall_building 商场楼座 + //{"A座":"B2层,B1层,1层,2层,3层,4层","B座":"1层,2层,3层"} + JSONObject obj= JSON.parseObject(wxProjectConfig.getMallBuilding()); + Iterator it =obj.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = (Map.Entry) it.next(); + //System.out.println(entry.getKey() + "-------" + entry.getValue()); + String[] split = entry.getValue().replace(",",",").split(","); + WxMallBuilding wxMallBuilding = new WxMallBuilding(); + wxMallBuilding.setTenantId(wxMall.getTenantId()); + wxMallBuilding.setMallId(wxMall.getId()); + wxMallBuilding.setBuildingName(entry.getKey()); + wxMallBuilding.setFloorNumber(split.length); + wxMallBuilding.setCreateDate(nowTime); + wxMallBuilding.setUpdateDate(nowTime); + wxMallBuildingMapper.insert(wxMallBuilding); + + for (String cha:split) { + WxMallFloor wxMallFloor = new WxMallFloor(); + wxMallFloor.setTenantId(wxMall.getTenantId()); + wxMallFloor.setMallId(wxMall.getId()); + wxMallFloor.setBuildingId(wxMallBuilding.getId()); + wxMallFloor.setFloorName(cha); + //默认图片---------------------------------------------------- + wxMallFloor.setBackgroundImg("https://s3.cn-northwest-1.amazonaws.com.cn/iformall-net/789/9eea8e0e-15ea-4be0-a43d-31e2e9d8db8c.jpg"); + wxMallFloor.setCreateDate(nowTime); + wxMallFloor.setUpdateDate(nowTime); + wxMallFloorMapper.insert(wxMallFloor); + } + } + + logger.info("wx_mall_building---floor ---------------------init--success"); + + //# --- 特殊商户号开通后,填写此数据 + //# 5. wx_pay_account + WxPayAccount wxPayAccount = new WxPayAccount(); + wxPayAccount.setTenantId(wxMall.getTenantId()); + wxPayAccount.setMchId(wxProjectConfig.getMchId()); + wxPayAccount.setSubMchId(wxProjectConfig.getSubMchId()); + wxPayAccount.setApiKey(wxProjectConfig.getApiKey()); + //----------------------------------------------------------- + //默认 +// wxPayAccount.setNotifyUrl(wxProjectConfig.getNotifyUrl()); +// wxPayAccount.setCertPath(wxProjectConfig.getCertPath()); + wxPayAccount.setNotifyUrl("https://admin.malls.iformall.com/wxPay/notify"); + wxPayAccount.setCertPath("/opt/iformall/service/apiclient_cert.p12"); + //------------------------------------------------------------- + wxPayAccount.setType(1);//0:普通商户模式, 1:服务商模式(默认服务商模式) + wxPayAccount.setShare(0);//0: 未分账,1:分账(默认不分账) + wxPayAccount.setRate(wxProjectConfig.getRate()); + wxPayAccount.setRealRate(wxProjectConfig.getRealRate()); + wxPayAccountMapper.insert(wxPayAccount); + + logger.info("wx_pay_account ---------------------init--success"); + + //# --- 特殊商户号开通后,填写此数据 + //# 6. wx_pay_account_bill + WxPayAccountBill wxPayAccountBill = new WxPayAccountBill(); + wxPayAccountBill.setTenantId(wxPayAccount.getTenantId()); + wxPayAccountBill.setMchId(wxPayAccount.getMchId()); + wxPayAccountBill.setSubMchId(wxPayAccount.getSubMchId()); + wxPayAccountBill.setApiKey(wxPayAccount.getApiKey()); + wxPayAccountBill.setNotifyUrl(wxPayAccount.getNotifyUrl()); + wxPayAccountBill.setCertPath(wxPayAccount.getCertPath()); + wxPayAccountBill.setType(wxPayAccount.getType()); + wxPayAccountBill.setShare(!(wxPayAccount.getShare() == 0)); + wxPayAccountBill.setRate(wxPayAccount.getRate()); + wxPayAccountBill.setRealRate(wxPayAccount.getRealRate()); + wxPayAccountBillMapper.insert(wxPayAccountBill); + + logger.info("wx_pay_account_bill ---------------------init--success"); + + + //# --- 小程序开通后,填写此数据,并设置域名及业务域名等 + //# 7. wx_appinfo + WxAppinfo wxAppinfo = new WxAppinfo(); + wxAppinfo.setTenantId(wxMall.getTenantId()); + wxAppinfo.setType(1); + wxAppinfo.setAppId(wxProjectConfig.getAppIdB()); + wxAppinfo.setParentAppId(wxProjectConfig.getParentAppId()); + wxAppinfo.setName(wxProjectConfig.getAppNameB()); + wxAppinfo.setSecret(wxProjectConfig.getAppSecretB()); + wxAppinfo.setPayId(wxPayAccount.getId()); + wxAppinfo.setPayBillId(wxPayAccountBill.getId()); + wxAppinfoMapper.insert(wxAppinfo); + wxAppinfo = new WxAppinfo(); + wxAppinfo.setTenantId(wxMall.getTenantId()); + wxAppinfo.setType(2); + wxAppinfo.setAppId(wxProjectConfig.getAppIdC()); + wxAppinfo.setParentAppId(wxProjectConfig.getParentAppId()); + wxAppinfo.setName(wxProjectConfig.getAppNameC()); + wxAppinfo.setSecret(wxProjectConfig.getAppSecretC()); + wxAppinfo.setPayId(wxPayAccount.getId()); + wxAppinfo.setPayBillId(wxPayAccountBill.getId()); + wxAppinfoMapper.insert(wxAppinfo); + + logger.info("wx_appinfo ---------------------init--success"); + + WxWeappExtSet wxWeappExtSet = new WxWeappExtSet(); + wxWeappExtSet.setAppId(wxProjectConfig.getAppIdB()); + wxWeappExtSet.setType(1); + wxWeappExtSet.setExtJson("{}"); + wxWeappExtSet.setReleaseJson("{}"); + wxWeappExtSet.setCreateDate(nowTime); + wxWeappExtSet.setUpdateDate(nowTime); + wxWeappExtSetMapper.insert(wxWeappExtSet); + wxWeappExtSet = new WxWeappExtSet(); + wxWeappExtSet.setAppId(wxProjectConfig.getAppIdC()); + wxWeappExtSet.setType(2); + wxWeappExtSet.setExtJson("{}"); + wxWeappExtSet.setReleaseJson("{}"); + wxWeappExtSet.setCarSupport(0); + wxWeappExtSet.setCreateDate(nowTime); + wxWeappExtSet.setUpdateDate(nowTime); + wxWeappExtSetMapper.insert(wxWeappExtSet); + + logger.info("wx_weapp_ext_set ---------------------init--success"); + + //生成id + //final IdWorker idWorker = IdWorker.get(); + //密码加密 + PasswordHelper passwordHelper = new PasswordHelper(); + // 9. mall_user_info mfadmin/m2F@of0 + // + MallUserInfo mallUserInfo = new MallUserInfo(); + //mallUserInfo.setId(idWorker.nextId()); + mallUserInfo.setTenantId(wxMall.getTenantId()); + mallUserInfo.setUsername(wxProjectConfig.getUsernameA()); + mallUserInfo.setName(wxProjectConfig.getName()); + //mallUserInfo.setPassword("2ddc17f6073a85dd7d7b030df5392364"); + mallUserInfo.setPassword(wxProjectConfig.getPassword()); + passwordHelper.encryptPassword(mallUserInfo); + mallUserInfo.setCreateTime(nowTime); + mallUserInfo.setStatus(1); + mallUserInfo.setIsAdmin(1); + mallUserInfo.setPhone(wxProjectConfig.getPhone()); + mallUserInfoMapper.insert(mallUserInfo); + + logger.info("mall_user_info ---------------------init--success"); + + //# 10. mall_role + MallRole mallRole = new MallRole(); + //mallRole.setId(idWorker.nextId()); + mallRole.setTenantId(wxMall.getTenantId()); + mallRole.setName("系统管理员"); + mallRole.setAvailable("0"); + mallRoleMapper.insert(mallRole); + + logger.info("mall_role ---------------------init--success"); + + //# 11. mall_role_permission + +// MallRolePermission mallRolePermission = new MallRolePermission(); +// mallRolePermission.setTenantId(wxMall.getTenantId()); +// mallRolePermission.setRoleId(mallRole.getId()); +// List mallRolePermissionList = new ArrayList(); +// for(int i=1;i<=10 ;i++){ +// mallRolePermission.setPermissionId((long) i); +// mallRolePermissionList.add(mallRolePermission); +// } +// mallRolePermission.setPermissionId((long) 50); +// mallRolePermissionList.add(mallRolePermission); +// mallRolePermissionMapper.insertBatch(mallRolePermissionList); + + //# 12. mall_user_role + MallUserRole mallUserRole = new MallUserRole(); + //mallUserRole.setId(idWorker.nextId()); + mallUserRole.setUid(mallUserInfo.getId()); + mallUserRole.setRoleId(mallRole.getId()); + mallUserRoleMapper.insert(mallUserRole); + + logger.info("mall_user_role ---------------------init--success"); + + //# 13. wx_msg_config + WxMsgConfig wxMsgConfig = new WxMsgConfig(); + wxMsgConfig.setTenantId(wxMall.getTenantId()); + wxMsgConfig.setSecret("7305150347587283553aa8898e7dbf20"); + wxMsgConfig.setPublickey("MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAvh8j/zagfxQdnSh5OIic\\r\\nMzN+MuRuWQJPjgu4Gza4+gX3j5Ln2xNDBOTjpwyuLBjh/JcBd1cGO3lAaKCwcaix\\r\\nsmhTq56wVXXUMgDiAChu4ud8FSvRc8G8tdZAirKVAIi3NW+/pYgpWBs/0wnF8hz4\\r\\n8no4pyJHl9Jc1LH3VNIMz8vqzKUPc4ack4pFUXlcNj6C+sBlaurmI4/vwLqNxBGs\\r\\n7/zyM7dv6oy3DSU/Y1qBArM1YPjfL2dNun8rmtPgJvlPwXqA7uoHPwQ2Ym3aUn59\\r\\npkS7QI6IE8uuqNkfSte8BXLd2nIqPLFxLYLDmdll7eoyRblHcHqAYSj8stK6StC7\\r\\nDNryNKEjTEwbgf9trUI0uvF1pfgTy2gpclnY69FtD/m0+FvLyorMq+nmBqYMjka5\\r\\nK0txDQJPOa7gsi//uXd/cJW2SAXY9MSO1AfMi8Xq/YKRQzN9FW5iapskXFHca7uX\\r\\ng5NhH7flr6DW+QInFlpoN6WIEAuDF1aj4O49Ikm3WxwhTqnvEkdSCfivpYQkp9Sh\\r\\n4kQ/SQdxuT7VX+Nz6k+uMx2z4cySk33bHi0KoHbA9QFGg/54Qd0+eU4qZnd4mrgh\\r\\nhH7/QQhL7Z9eF1U5UPrsHq2Vq3rEnN+tYQ26AuKeU8vzTxBrC/SxC6C/SMFt3f/Y\\r\\nnuFh1UnNJZleZwyQt+ZdGO0CAwEAAQ=="); + wxMsgConfig.setBid("465565"); + wxMsgConfig.setRecharge((long) 0); + wxMsgConfig.setRemains((long) 100000); + wxMsgConfig.setTotal((long) 100000); + wxMsgConfig.setAccount("15626593768"); + wxMsgConfig.setReminderstatus(0); + wxMsgConfig.setNotifyurl("https://admin.malls.iformall.com/wxMsgCallback/receivemsg/"+wxMall.getTenantId()); + wxMsgConfig.setModelnotifyurl("https://admin.malls.iformall.com/wxMsgCallback/receivemodel/"+wxMall.getTenantId()); + wxMsgConfig.setVerifynotifyurl("https://admin.malls.iformall.com/wxMsgCallback/receiveverifymodel/"+wxMall.getTenantId()); + wxMsgConfig.setAppid(wxProjectConfig.getAppIdB()); + wxMsgConfigMapper.insert(wxMsgConfig); + + logger.info("wx_msg_config ---------------------init--success"); + + + //# --- 14. ETCP 设置完后再填写此数据 + //# 14. wx_park + WxPark wxPark = new WxPark(); + wxPark.setVendorParams("{}"); + wxPark.setCreateDate(nowTime); + wxPark.setUpdateDate(nowTime); + wxPark.setAddr(wxProjectConfig.getName()); + wxPark.setTenantId(wxMall.getTenantId()); + wxPark.setNumber(wxMall.getParkPlaceNumber()); + wxPark.setVendorType(0); + wxPark.setParkId("0"); + wxPark.setEntryExit(1); + wxPark.setStopFee(""); + wxParkMapper.insert(wxPark); + + logger.info("wx_park ---------------------init--success"); + + + //# 积分成长值设置wx_score_rules + WxScoreRules wxScoreRules = new WxScoreRules(); + //wxScoreRules.setId(idWorker.nextId()); + wxScoreRules.setTenantId(wxMall.getTenantId()); + wxScoreRules.setRules("[{\"id\": 1, \"desc\": \"每日登陆\", \"step\": 1, \"limit\": 0, \"score\": 0}, {\"id\": 2, \"score\": null, \"childs\": [{\"desc\": \"线上交易1元\", \"step\": 1, \"limit\": 0, \"score\": 0, \"title\": \"餐饮\", \"businessId\": 1}, {\"desc\": \"线上交易1元\", \"step\": 1, \"limit\": 0, \"score\": 0, \"title\": \"娱乐\", \"businessId\": 2}, {\"desc\": \"线上交易1元\", \"step\": 1, \"limit\": 0, \"score\": 0, \"title\": \"服饰\", \"businessId\": 3}, {\"desc\": \"线上交易1元\", \"step\": 1, \"limit\": 0, \"score\": 0, \"title\": \"亲子\", \"businessId\": 4}, {\"desc\": \"线上交易1元\", \"step\": 1, \"limit\": 0, \"score\": 0, \"title\": \"超市\", \"businessId\": 5}, {\"desc\": \"线上交易1元\", \"step\": 1, \"limit\": 0, \"score\": 0, \"title\": \"美妆\", \"businessId\": 7}, {\"desc\": \"线上交易1元\", \"step\": 1, \"limit\": 0, \"score\": 0, \"title\": \"珠宝\", \"businessId\": 8}, {\"desc\": \"线上交易1元\", \"step\": 1, \"limit\": 0, \"score\": 0, \"title\": \"服务\", \"businessId\": 9}, {\"desc\": \"线上交易1元\", \"step\": 1, \"limit\": 0, \"score\": 0, \"title\": \"家居\", \"businessId\": 10}, {\"desc\": \"线上交易1元\", \"step\": 1, \"limit\": 0, \"score\": 0, \"title\": \"数码家电\", \"businessId\": 11}, {\"desc\": \"线上交易1元\", \"step\": 1, \"limit\": 0, \"score\": 0, \"title\": \"其他\", \"businessId\": 6}]}, {\"id\": 3, \"desc\": \"绑定车牌1个\", \"step\": 1, \"limit\": 1, \"score\": 0}, {\"id\": 5, \"desc\": \"授权个人信息\", \"step\": 1, \"limit\": 1, \"score\": 0}, {\"id\": 6, \"desc\": \"授权手机号\", \"step\": 1, \"limit\": 1, \"score\": 0}, {\"id\": 7, \"desc\": \"编辑个人信息\", \"step\": 1, \"limit\": 1, \"score\": 0}, {\"id\": 8, \"desc\": \"编辑个人信息\", \"step\": 1, \"limit\": 1, \"score\": 0}]"); + wxScoreRules.setCreateDate(nowTime); + wxScoreRules.setUpdateDate(nowTime); + wxScoreRules.setType(2); + wxScoreRules.setClearYear(1); + wxScoreRules.setScale(10); + wxScoreRules.setCreditLocked(1); + wxScoreRulesMapper.insert(wxScoreRules); + wxScoreRules = new WxScoreRules(); + wxScoreRules.setTenantId(wxMall.getTenantId()); + wxScoreRules.setRules("[{\"id\": 1, \"desc\": \"每日登陆\", \"step\": 1, \"limit\": 0, \"score\": 0}, {\"id\": 2, \"score\": 0, \"childs\": [{\"desc\": \"线上交易1元\", \"step\": 1, \"limit\": 0, \"score\": 0, \"title\": \"餐饮\", \"businessId\": 1}, {\"desc\": \"线上交易1元\", \"step\": 1, \"limit\": 0, \"score\": 0, \"title\": \"娱乐\", \"businessId\": 2}, {\"desc\": \"线上交易1元\", \"step\": 1, \"limit\": 0, \"score\": 0, \"title\": \"服饰\", \"businessId\": 3}, {\"desc\": \"线上交易1元\", \"step\": 1, \"limit\": 0, \"score\": 0, \"title\": \"亲子\", \"businessId\": 4}, {\"desc\": \"线上交易1元\", \"step\": 1, \"limit\": 0, \"score\": 0, \"title\": \"超市\", \"businessId\": 5}, {\"desc\": \"线上交易1元\", \"step\": 1, \"limit\": 0, \"score\": 0, \"title\": \"美妆\", \"businessId\": 7}, {\"desc\": \"线上交易1元\", \"step\": 1, \"limit\": 0, \"score\": 0, \"title\": \"珠宝\", \"businessId\": 8}, {\"desc\": \"线上交易1元\", \"step\": 1, \"limit\": 0, \"score\": 0, \"title\": \"服务\", \"businessId\": 9}, {\"desc\": \"线上交易1元\", \"step\": 1, \"limit\": 0, \"score\": 0, \"title\": \"家居\", \"businessId\": 10}, {\"desc\": \"线上交易1元\", \"step\": 1, \"limit\": 0, \"score\": 0, \"title\": \"数码家电\", \"businessId\": 11}, {\"desc\": \"线上交易1元\", \"step\": 1, \"limit\": 0, \"score\": 0, \"title\": \"其他\", \"businessId\": 6}]}, {\"id\": 3, \"desc\": \"绑定车牌1个\", \"step\": 1, \"limit\": 1, \"score\": 0}, {\"id\": 5, \"desc\": \"授权个人信息\", \"step\": 1, \"limit\": 1, \"score\": 0}, {\"id\": 6, \"desc\": \"授权手机号\", \"step\": 1, \"limit\": 1, \"score\": 0}, {\"id\": 7, \"desc\": \"编辑个人信息\", \"step\": 1, \"limit\": 1, \"score\": 0}]"); + wxScoreRules.setCreateDate(nowTime); + wxScoreRules.setUpdateDate(nowTime); + wxScoreRules.setType(1); + wxScoreRules.setCreditLocked(0); + wxScoreRulesMapper.insert(wxScoreRules); + + logger.info("wx_score_rules ---------------------init--success"); + + //# 17. wx_template_msg + //# C端登录,设置域名 + //# 设置核销成功通知,核销失败通知 + WxTemplateMsg wxTemplateMsg = new WxTemplateMsg(); + wxTemplateMsg.setTenantId(wxMall.getTenantId()); + wxTemplateMsg.setTemplateId(""); + wxTemplateMsg.setType(1); + wxTemplateMsg.setCustomParam("{\"index\":[\"keyword1\",\"keyword2\",\"keyword3\",\"keyword4\",\"keyword5\",\"keyword6\",\"keyword7\"],\"keyword1\":\"可抵{keyword1}元\",\"keyword2\":\"{keyword2}\",\"keyword3\":\"{keyword3}\",\"keyword4\":\"{keyword4}\",\"keyword5\":\"{keyword5}元\",\"keyword6\":\"{keyword6}\",\"keyword7\":\"猜也猜不到的优惠,只有幸运的人才能看到,就是你,{keyword7}\\n☟☟☟☟☟☟☟\\n☞ 快看看 ☜\\n☝︎☝︎☝︎☝︎☝︎☝︎☝︎\\n\",\"emphasis\":\"keyword1.DATA\"}"); + wxTemplateMsg.setCreateDate(nowTime); + wxTemplateMsg.setUpdateDate(nowTime); + wxTemplateMsgMapper.insert(wxTemplateMsg); + wxTemplateMsg.setId(null); + wxTemplateMsg.setType(2); + wxTemplateMsg.setCustomParam("{\"index\":[\"keyword1\",\"keyword2\",\"keyword3\",\"keyword4\"],\"keyword1\":\"可抵{keyword1}元\",\"keyword2\":\"{keyword2}\",\"keyword3\":\"{keyword3}\",\"keyword4\":\"猜也猜不到的优惠,只有幸运的人才能看到,就是你,{keyword4}\\n☟☟☟☟☟☟☟\\n☞ 快看看 ☜\\n☝︎☝︎☝︎☝︎☝︎☝︎☝︎\\n\",\"emphasis\":\"keyword1.DATA\"}"); + wxTemplateMsgMapper.insert(wxTemplateMsg); + + logger.info("wx_template_msg ---------------------init--success"); + +// # 18. wx_wiwide_info -- 迈外迪 服务商后台设置商户(点击获取商户bid),再找迈外迪初始化,收到激活邮件激活后,再在数据库中插入此数据 +// # 数据格式如下 +// # szld1086@iformall +// # 1391054397 +// # wuguoqiang@iformall.com + // WxWiWideInfo wxWiWideInfo = new WxWiWideInfo(); + + + + // # 19. wx_question + String questionJson = "[{\"flag\": \"single\", \"title\": \"请问您的职业是?\", \"answers\": [{\"id\": \"59\", \"name\": \"学生\"}, {\"id\": \"60\", \"name\": \"上班族\"}, {\"id\": \"61\", \"name\": \"企业高管\"}, {\"id\": \"62\", \"name\": \"个体户\"}, {\"id\": \"63\", \"name\": \"自由职业\"}, {\"id\": \"64\", \"name\": \"其他\"}]}," + + "{\"flag\": \"single\", \"title\": \"请问您目前的学历是?\", \"answers\": [{\"id\": \"34\", \"name\": \"高中\"}, {\"id\": \"35\", \"name\": \"大专\"}, {\"id\": \"36\", \"name\": \"本科\"}, {\"id\": \"37\", \"name\": \"硕士及以上\"}, {\"id\": \"38\", \"name\": \"博士及以上\"}]}," + + "{\"flag\": \"single\", \"title\": \"请问您是如何到达商场的?\", \"answers\": [{\"id\": \"127\", \"name\": \"走路\"}, {\"id\": \"128\", \"name\": \"乘车\"}]}," + + "{\"flag\": \"single\", \"title\": \"请问您和父母一起居住吗?\", \"answers\": [{\"id\": \"65\", \"name\": \"不是,我已租房\"}, {\"id\": \"66\", \"name\": \"是,我已购房\"}, {\"id\": \"67\", \"name\": \"不是,我和室友住宿舍\"}]}," + + "{\"flag\": \"multi\", \"title\": \"请问您的孩子愿意与您一起?\", \"answers\": [{\"id\": \"57\", \"name\": \"逛街\"}, {\"id\": \"57\", \"name\": \"玩乐\"}, {\"id\": \"57\", \"name\": \"阅读\"}, {\"id\": \"55\", \"name\": \"我还没有宝宝\"}]}," + + "{\"flag\": \"single\", \"title\": \"主人,您结婚了吗?\", \"answers\": [{\"id\": \"56\", \"name\": \"结婚啦\"}, {\"id\": \"55\", \"name\": \"还没有哦\"}]}," + + "{\"flag\": \"single\", \"title\": \"您是?\", \"answers\": [{\"id\": \"42\", \"name\": \"贫下中农\"}, {\"id\": \"43\", \"name\": \"小康家庭\"}, {\"id\": \"44\", \"name\": \"中产家庭\"}, {\"id\": \"45\", \"name\": \"富裕家庭\"}]}," + + "{\"flag\": \"single\", \"title\": \"请问您是?\", \"answers\": [{\"id\": \"104\", \"name\": \"实惠型消费\"}, {\"id\": \"105\", \"name\": \"享乐型消费\"}, {\"id\": \"106\", \"name\": \"品质型消费\"}]}," + + "{\"flag\": \"multi\", \"title\": \"请问您喜欢哪种口味的食物?\", \"answers\": [{\"id\": \"92\", \"name\": \"轻餐\"}, {\"id\": \"93\", \"name\": \"小吃快餐\"}, {\"id\": \"94\", \"name\": \"西餐\"}, {\"id\": \"95\", \"name\": \"日料中餐甜点\"}, {\"id\": \"96\", \"name\": \"火锅\"}]}," + + "{\"flag\": \"multi\", \"title\": \"请问您的爱好是?\", \"answers\": [{\"id\": \"121\", \"name\": \"时尚\"}, {\"id\": \"122\", \"name\": \"旅游\"}, {\"id\": \"123\", \"name\": \"运动\"}, {\"id\": \"124\", \"name\": \"电玩\"}, {\"id\": \"125\", \"name\": \"看书\"}, {\"id\": \"126\", \"name\": \"其他\"}]}]"; + WxQuestion wxQuestion = new WxQuestion(); + wxQuestion.setTenantId(wxMall.getTenantId()); + JSONArray jsonObject = JSON.parseArray(questionJson); + for (Object object : jsonObject) { + wxQuestion.setId(null); + wxQuestion.setContent(object.toString()); + wxQuestionMapper.insert(wxQuestion); + } + + logger.info("wx_question ---------------------init--success"); + + //# 20. wx_msg_validationcode_model, 数据重新一下 + //--------EnumMsgModel +// WxMsgValidationcodeModel wxMsgValidationcodeModel = new WxMsgValidationcodeModel(); + +// WxFlowConfig wxFlowConfig = new WxFlowConfig(); + //初始化成功 删除标记 + wxProjectConfig.setDelType(10000); + wxProjectConfigMapper.updateById(wxProjectConfig); + + + logger.info("init--success----------------tenantId--"+wxMall.getTenantId()); + + + }else { + logger.info("------数据已初始化"); + } + + } + + +} diff --git a/mallinkService/src/main/java/com/iformall/utils/PasswordHelper.java b/mallinkService/src/main/java/com/iformall/utils/PasswordHelper.java new file mode 100644 index 000000000..030d3113b --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/utils/PasswordHelper.java @@ -0,0 +1,34 @@ +package com.iformall.utils; + + +import com.iformall.domain.po.MallUserInfo; +import org.apache.shiro.crypto.hash.SimpleHash; +import org.apache.shiro.util.ByteSource; + + +public class PasswordHelper { + //private RandomNumberGenerator randomNumberGenerator = new SecureRandomNumberGenerator(); + private String algorithmName = "md5"; + private int hashIterations = 2; + + public void encryptPassword(MallUserInfo user) { + //String salt=randomNumberGenerator.nextBytes().toHex(); + String newPassword = new SimpleHash(algorithmName, user.getPassword(), ByteSource.Util.bytes(user.getUsername()), hashIterations).toHex(); + //String newPassword = new SimpleHash(algorithmName, user.getPassword()).toHex(); + user.setPassword(newPassword); + + } + + + public static void main(String[] args) { + MallUserInfo user = new MallUserInfo(); + user.setUsername("mfadmin"); + user.setPassword("m2F@of0"); + PasswordHelper passwordHelper = new PasswordHelper(); + passwordHelper.encryptPassword(user); + System.out.println(user); + System.out.println(user.getPassword()); + } + + +} diff --git a/mallinkService/src/main/resources/mapper/WxProjectConfigMapper.xml b/mallinkService/src/main/resources/mapper/WxProjectConfigMapper.xml new file mode 100644 index 000000000..b3dcd6315 --- /dev/null +++ b/mallinkService/src/main/resources/mapper/WxProjectConfigMapper.xml @@ -0,0 +1,5 @@ + + + + +