Browse Source

Merge branch 'developer' of git_lijun/caimei-mall into developer

李俊 5 years ago
parent
commit
7080671821

+ 1 - 1
pom.xml

@@ -124,7 +124,7 @@
                 <artifactId>spring-boot-maven-plugin</artifactId>
                 <version>1.5.2.RELEASE</version>
                 <configuration>
-                    <mainClass>lk.ArticleApplication</mainClass><!--springboot启动类目录-->
+                    <mainClass>com.caimei.StartApplication</mainClass><!--springboot启动类目录-->
                 </configuration>
                 <executions>
                     <execution>

+ 177 - 0
src/main/java/com/caimei/controller/user/LoginController.java

@@ -0,0 +1,177 @@
+package com.caimei.controller.user;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.caimei.entity.CmOperationUser;
+import com.caimei.entity.WxJsonModel;
+import com.caimei.service.user.LoginService;
+import com.caimei.utils.HttpRequest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Controller;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 登录
+ */
+@Controller
+@RequestMapping("/login")
+public class LoginController {
+    protected static final Logger logger = LoggerFactory.getLogger(LoginController.class);
+    @Autowired
+    private LoginService loginService;
+
+    @Value("${miniprogram.AppId}")
+    private String AppId;
+
+    @Value("${miniprogram.AppSecret}")
+    private String AppSecret;
+
+    /**
+     * 判断是否是游客
+     *
+     * @param code
+     * @param request
+     * @return
+     */
+    @ResponseBody
+    @RequestMapping("/doLogin")
+    public WxJsonModel doLogin(@RequestParam(value = "code", required = true) String code,
+                               @RequestParam(value = "userOrganizeID") Integer userOrganizeID,
+                               HttpServletRequest request) {
+        logger.info("Start get SessionKey");
+        WxJsonModel res = WxJsonModel.newInstance();
+        Map<String, Object> map = new HashMap<>();
+        String referer = request.getHeader("Referer"); //获取当前微信小程序的环境
+        logger.info("referer-is----:" + referer);
+        map.put("referer", referer);
+        String requestUrl = "https://api.weixin.qq.com/sns/jscode2session";
+        Map<String, String> requestUrlParam = new HashMap<String, String>();
+        requestUrlParam.put("appid", AppId);//小程序appId
+        requestUrlParam.put("secret", AppSecret);//小程序appsecret
+        requestUrlParam.put("js_code", code);//小程序端返回的code
+        requestUrlParam.put("grant_type", "authorization_code");//默认参数
+        //发送post请求读取调用微信接口获取openid用户唯一标识
+        String infos;
+        try {
+            infos = HttpRequest.sendPost(requestUrl, requestUrlParam);
+        } catch (Exception e) {
+            res.setData(map);
+            return res.error("服务器内部异常");
+        }
+        //解析相应内容(转换成json对象)
+        JSONObject jsonObject = JSON.parseObject(infos);
+        String openid = jsonObject.getString("openid");
+        logger.info("openid----->" + openid);
+        String session_key = jsonObject.getString("session_key");
+        String errcode = jsonObject.getString("errcode");
+        String errmsg = jsonObject.getString("errmsg");
+        if (!StringUtils.isEmpty(errcode) &&
+                (errcode.equals("-1") || errcode.equals("40029") || errcode.equals("45011"))) {
+            res.setMsg(errmsg);
+            res.setData(map);
+            map.put("sessionKey", session_key);
+            res.setCode("-1");
+            return res;
+        }
+        CmOperationUser operationUser = loginService.doLogin(openid, userOrganizeID);
+        if (operationUser == null) {
+            return res.error("-1", "游客,请登录");
+        }
+        return res.success("1", operationUser);
+    }
+
+    /**
+     * 判断邀请码是否有效
+     *
+     * @param invitationCode 邀请码
+     * @param userOrganizeID 组织id
+     * @return
+     */
+    @RequestMapping("/isEnabled")
+    @ResponseBody
+    public WxJsonModel isEnabled(String invitationCode, Integer userOrganizeID) {
+        WxJsonModel res = WxJsonModel.newInstance();
+        CmOperationUser operationUser = loginService.isEnabled(invitationCode, userOrganizeID);
+        if (operationUser == null) {
+            return res.error("-1", "邀请码错误");
+        }
+        Date date = new Date();
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(operationUser.getInvitationCodeTime());
+        calendar.add(Calendar.DATE, 2);
+        if (operationUser.getStatus().equals("1") && date.getTime() > calendar.getTime().getTime() && operationUser.getDelFlag().equals("0")) {
+            return res.error("-1", "邀请码已失效");
+        }
+        if (operationUser.getStatus().equals("2") && operationUser.getDelFlag().equals("0")) {
+            return res.error("-1", "邀请码已被使用");
+        }
+        if (!operationUser.getDelFlag().equals("0")) {
+            return res.error("-1", "您的账号已下线");
+        }
+        if (operationUser.getClubStatus().equals("91")) {
+            return res.error("-1", "您所在的会所已下线");
+        }
+        return res.error("1", "邀请码通过");
+    }
+
+
+    /**
+     * 注册并登录
+     *
+     * @param code
+     * @param request
+     * @return
+     */
+    @RequestMapping("/register")
+    @ResponseBody
+    public WxJsonModel register(@RequestParam(value = "code", required = true) String code,
+                                CmOperationUser operationUser, HttpServletRequest request) {
+        WxJsonModel res = WxJsonModel.newInstance();
+        Map<String, Object> map = new HashMap<>();
+        String referer = request.getHeader("Referer"); //获取当前微信小程序的环境
+        map.put("referer", referer);
+        String requestUrl = "https://api.weixin.qq.com/sns/jscode2session";
+        Map<String, String> requestUrlParam = new HashMap<String, String>();
+        requestUrlParam.put("appid", AppId);//小程序appId
+        requestUrlParam.put("secret", AppSecret);//小程序appsecret
+        requestUrlParam.put("js_code", code);//小程序端返回的code
+        requestUrlParam.put("grant_type", "authorization_code");//默认参数
+        //发送post请求读取调用微信接口获取openid用户唯一标识
+        String infos;
+        try {
+            infos = HttpRequest.sendPost(requestUrl, requestUrlParam);
+        } catch (Exception e) {
+            res.setData(map);
+            return res.error("服务器内部异常");
+        }
+        //解析相应内容(转换成json对象)
+        JSONObject jsonObject = JSON.parseObject(infos);
+        String openid = jsonObject.getString("openid");
+        String session_key = jsonObject.getString("session_key");
+        String errcode = jsonObject.getString("errcode");
+        String errmsg = jsonObject.getString("errmsg");
+        if (!StringUtils.isEmpty(errcode) &&
+                (errcode.equals("-1") || errcode.equals("40029") || errcode.equals("45011"))) {
+            res.setMsg(errmsg);
+            res.setData(map);
+            map.put("sessionKey", session_key);
+            res.setCode("-1");
+            return res;
+        }
+        operationUser.setOpenid(openid);
+        loginService.update(operationUser);
+        return res.success("1", operationUser);
+    }
+}

+ 141 - 0
src/main/java/com/caimei/controller/user/PersonalController.java

@@ -0,0 +1,141 @@
+package com.caimei.controller.user;
+
+import com.caimei.entity.*;
+import com.caimei.service.user.PersonalService;
+import com.github.pagehelper.PageHelper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 个人中心
+ */
+@Controller
+@RequestMapping("/personal")
+public class PersonalController {
+    @Autowired
+    private PersonalService personalService;
+
+    /**
+     * 我的个人显示数据
+     *
+     * @param operationUser
+     * @return
+     */
+    @RequestMapping("/myCentre")
+    @ResponseBody
+    public WxJsonModel myCentre(CmOperationUser operationUser) {
+        WxJsonModel res = WxJsonModel.newInstance();
+        Club club = personalService.myCentre(operationUser);
+        return res.success("1", club);
+    }
+
+    /**
+     * 账户余额明细
+     *
+     * @return
+     */
+    @ResponseBody
+    @RequestMapping("/touchBalance")
+    public Map<String, Object> touchBalance(int year, int month, Integer index, Integer pageSize, CmUserBalanceRecord balanceRecord) {
+        Map<String, Object> map = personalService.touchBalance(index, pageSize, year, month, balanceRecord);
+        return map;
+    }
+
+    /**
+     * 地址管理:省市区
+     */
+    @ResponseBody
+    @RequestMapping("/address")
+    public List<Province> address() {
+        List<Province> list = personalService.address();
+        return list;
+    }
+
+    /**
+     * 省
+     */
+    @ResponseBody
+    @RequestMapping("/province")
+    public List<Province> getProvince() {
+        List<Province> provinceList = personalService.getProvince();
+        return provinceList;
+    }
+
+    /**
+     * 市
+     */
+    @ResponseBody
+    @RequestMapping("/city")
+    public List<City> getCity(Long provinceid) {
+        List<City> cityList = personalService.getCity(provinceid);
+        return cityList;
+    }
+
+    /**
+     * 区
+     */
+    @ResponseBody
+    @RequestMapping("/town")
+    public List<Town> getTown(Integer cityid) {
+        List<Town> townList = personalService.getTown(cityid);
+        return townList;
+    }
+
+    /**
+     * 查询用户所有地址
+     *
+     * @param userID
+     * @return
+     */
+    @ResponseBody
+    @RequestMapping("/findAddress")
+    public Page<Address> findAddress(Integer userID, Integer index, Integer pageSize) {
+        if (index == null) index = 1;
+        if (pageSize == null) pageSize = 10;
+        PageHelper.startPage(index, pageSize);
+        List<Address> addressList = personalService.findAddress(userID);
+        Page<Address> page = new Page<>(addressList);
+        return page;
+    }
+
+    /**
+     * 保存或编辑地址
+     *
+     * @return
+     */
+    @ResponseBody
+    @RequestMapping(value = "/save", method = RequestMethod.POST)
+    public WxJsonModel saveAddress(@RequestBody Address address) {
+        WxJsonModel res = WxJsonModel.newInstance();
+        if (address == null) return res.error("参数异常");
+        try {
+            personalService.saveAddress(address);
+        } catch (Exception e) {
+            return res.error("保存失败");
+        }
+        return res.success("保存成功", "");
+    }
+
+    /**
+     * 删除地址
+     */
+    @ResponseBody
+    @RequestMapping("/delete")
+    public WxJsonModel deleteAddress(Integer addressID) {
+        WxJsonModel res = WxJsonModel.newInstance();
+        try {
+            personalService.deleteAddress(addressID);
+        } catch (Exception e) {
+            return res.error("删除失败");
+        }
+        return res.success("删除成功", "");
+    }
+
+}

+ 114 - 0
src/main/java/com/caimei/entity/Address.java

@@ -0,0 +1,114 @@
+package com.caimei.entity;
+
+import java.io.Serializable;
+
+public class Address implements Serializable {
+    private Integer addressID; //用户地址ID
+    private Integer userID; //用户ID
+    private String shouHuoRen; //收货人
+    private Integer townID; //区ID
+    private String addressDetail; //地址
+    private String postalCode; //邮编
+    private String phone; //电话
+    private String mobile; //手机
+    private String defaultFlag; //是否默认收货地址(0 不是默认,1 默认)
+    private String town;//村镇名
+    private String city;//城市名称
+    private String province;//省份名称
+
+    public Integer getAddressID() {
+        return addressID;
+    }
+
+    public void setAddressID(Integer addressID) {
+        this.addressID = addressID;
+    }
+
+    public Integer getUserID() {
+        return userID;
+    }
+
+    public void setUserID(Integer userID) {
+        this.userID = userID;
+    }
+
+    public String getShouHuoRen() {
+        return shouHuoRen;
+    }
+
+    public void setShouHuoRen(String shouHuoRen) {
+        this.shouHuoRen = shouHuoRen;
+    }
+
+    public Integer getTownID() {
+        return townID;
+    }
+
+    public void setTownID(Integer townID) {
+        this.townID = townID;
+    }
+
+    public String getAddressDetail() {
+        return addressDetail;
+    }
+
+    public void setAddressDetail(String addressDetail) {
+        this.addressDetail = addressDetail;
+    }
+
+    public String getPostalCode() {
+        return postalCode;
+    }
+
+    public void setPostalCode(String postalCode) {
+        this.postalCode = postalCode;
+    }
+
+    public String getPhone() {
+        return phone;
+    }
+
+    public void setPhone(String phone) {
+        this.phone = phone;
+    }
+
+    public String getMobile() {
+        return mobile;
+    }
+
+    public void setMobile(String mobile) {
+        this.mobile = mobile;
+    }
+
+    public String getDefaultFlag() {
+        return defaultFlag;
+    }
+
+    public void setDefaultFlag(String defaultFlag) {
+        this.defaultFlag = defaultFlag;
+    }
+
+    public String getTown() {
+        return town;
+    }
+
+    public void setTown(String town) {
+        this.town = town;
+    }
+
+    public String getCity() {
+        return city;
+    }
+
+    public void setCity(String city) {
+        this.city = city;
+    }
+
+    public String getProvince() {
+        return province;
+    }
+
+    public void setProvince(String province) {
+        this.province = province;
+    }
+}

+ 53 - 0
src/main/java/com/caimei/entity/City.java

@@ -0,0 +1,53 @@
+package com.caimei.entity;
+
+
+import java.io.Serializable;
+import java.util.List;
+
+public class City implements Serializable {
+    private Integer cityid; //市ID
+    private Integer provinceid; //所属省ID
+    private String name;        //市名
+    private String validflag;   //是否有效(0 无效,1 有效)
+    private List<Town> towns;   //下面的区
+
+    public Integer getCityid() {
+        return cityid;
+    }
+
+    public void setCityid(Integer cityid) {
+        this.cityid = cityid;
+    }
+
+    public Integer getProvinceid() {
+        return provinceid;
+    }
+
+    public void setProvinceid(Integer provinceid) {
+        this.provinceid = provinceid;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getValidflag() {
+        return validflag;
+    }
+
+    public void setValidflag(String validflag) {
+        this.validflag = validflag;
+    }
+
+    public List<Town> getTowns() {
+        return towns;
+    }
+
+    public void setTowns(List<Town> towns) {
+        this.towns = towns;
+    }
+}

+ 78 - 0
src/main/java/com/caimei/entity/Club.java

@@ -0,0 +1,78 @@
+package com.caimei.entity;
+
+import java.io.Serializable;
+
+public class Club implements Serializable {
+    private Integer clubID;
+    private Integer userID;
+    private Integer clubTypeID;//会所类型
+    private String name;//会所名称
+    private String headpic; //门头照
+    private Double ableUserMoney; //账户实际可用余额
+    private String contactNumber;   //联系我们
+    private String introduction;    //关于我们
+
+    public Integer getClubID() {
+        return clubID;
+    }
+
+    public void setClubID(Integer clubID) {
+        this.clubID = clubID;
+    }
+
+    public Integer getUserID() {
+        return userID;
+    }
+
+    public void setUserID(Integer userID) {
+        this.userID = userID;
+    }
+
+    public Integer getClubTypeID() {
+        return clubTypeID;
+    }
+
+    public void setClubTypeID(Integer clubTypeID) {
+        this.clubTypeID = clubTypeID;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getHeadpic() {
+        return headpic;
+    }
+
+    public void setHeadpic(String headpic) {
+        this.headpic = headpic;
+    }
+
+    public Double getAbleUserMoney() {
+        return ableUserMoney;
+    }
+
+    public void setAbleUserMoney(Double ableUserMoney) {
+        this.ableUserMoney = ableUserMoney;
+    }
+
+    public String getContactNumber() {
+        return contactNumber;
+    }
+
+    public void setContactNumber(String contactNumber) {
+        this.contactNumber = contactNumber;
+    }
+
+    public String getIntroduction() {
+        return introduction;
+    }
+
+    public void setIntroduction(String introduction) {
+        this.introduction = introduction;
+    }
+}

+ 151 - 0
src/main/java/com/caimei/entity/CmOperationUser.java

@@ -0,0 +1,151 @@
+package com.caimei.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+
+public class CmOperationUser implements Serializable {
+    private Integer id;
+    private Integer userOrganizeID;      //具体对应cm_user_organize表ID
+    private Integer clubID;              //会所ID:隶属于哪个会所的运营人员
+    private String mobile;              //手机号码
+    private String linkName;            //联系人
+    private String invitationCode;      //邀请码
+    private String status;              //1未绑定,2已绑定
+    private String nickName;            //微信昵称
+    private String openid;               //小程序openid
+    private Date invitationCodeTime;    //邀请码生成时间(此时间起48小时有效)
+    private Date bindTime;              //绑定时间
+    private Date updateTime;            //更新时间
+    private Date addTime;               //添加时间
+    private String delFlag;              //0 有效 其它无效
+    private String clubStatus;          //会所状态  (90, "已上线"),(91, "已冻结")
+    private Integer userID;             //用户ID:隶属于哪个用户的运营人员
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getUserOrganizeID() {
+        return userOrganizeID;
+    }
+
+    public void setUserOrganizeID(Integer userOrganizeID) {
+        this.userOrganizeID = userOrganizeID;
+    }
+
+    public Integer getClubID() {
+        return clubID;
+    }
+
+    public void setClubID(Integer clubID) {
+        this.clubID = clubID;
+    }
+
+    public String getMobile() {
+        return mobile;
+    }
+
+    public void setMobile(String mobile) {
+        this.mobile = mobile;
+    }
+
+    public String getLinkName() {
+        return linkName;
+    }
+
+    public void setLinkName(String linkName) {
+        this.linkName = linkName;
+    }
+
+    public String getInvitationCode() {
+        return invitationCode;
+    }
+
+    public void setInvitationCode(String invitationCode) {
+        this.invitationCode = invitationCode;
+    }
+
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
+
+    public String getNickName() {
+        return nickName;
+    }
+
+    public void setNickName(String nickName) {
+        this.nickName = nickName;
+    }
+
+    public String getOpenid() {
+        return openid;
+    }
+
+    public void setOpenid(String openid) {
+        this.openid = openid;
+    }
+
+    public Date getInvitationCodeTime() {
+        return invitationCodeTime;
+    }
+
+    public void setInvitationCodeTime(Date invitationCodeTime) {
+        this.invitationCodeTime = invitationCodeTime;
+    }
+
+    public Date getBindTime() {
+        return bindTime;
+    }
+
+    public void setBindTime(Date bindTime) {
+        this.bindTime = bindTime;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public Date getAddTime() {
+        return addTime;
+    }
+
+    public void setAddTime(Date addTime) {
+        this.addTime = addTime;
+    }
+
+    public String getDelFlag() {
+        return delFlag;
+    }
+
+    public void setDelFlag(String delFlag) {
+        this.delFlag = delFlag;
+    }
+
+    public String getClubStatus() {
+        return clubStatus;
+    }
+
+    public void setClubStatus(String clubStatus) {
+        this.clubStatus = clubStatus;
+    }
+
+    public Integer getUserID() {
+        return userID;
+    }
+
+    public void setUserID(Integer userID) {
+        this.userID = userID;
+    }
+}

+ 147 - 0
src/main/java/com/caimei/entity/CmUserBalanceRecord.java

@@ -0,0 +1,147 @@
+package com.caimei.entity;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.util.Date;
+
+public class CmUserBalanceRecord implements Serializable {
+    private Integer userId;        // 用户ID
+    private Integer userOrganizeID;  //组织id
+    private String type;        // 收支类型:1收入,2支出
+    private String balanceType;        // '余额类型:1余额抵扣,2多收退款到余额,3申请退款,4余额充值,5余额提现',
+    @DateTimeFormat(pattern = "yyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date addDate;        // 添加时间
+    private String amount;        // 金额
+    private Integer orderId;        // 主订单ID(适用余额类型1,3[类型为3多次退款存在相同记录ID则需通过退款ID唯一区分])
+    private Integer receiptId;        // 收款ID(适用余额类型2)
+    private Integer returnedId;        // 退货退款ID(适用余额类型3)
+    private Integer withdrawalsId;        // 用户提现ID
+    private String remark;        // 备注
+    private String userName; //用户名称
+    private String ableUserMoney;//用户可用余额
+    private String startTime;   //开始时间
+    private String endTime;     //结束时间
+
+    public Integer getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Integer userId) {
+        this.userId = userId;
+    }
+
+    public Integer getUserOrganizeID() {
+        return userOrganizeID;
+    }
+
+    public void setUserOrganizeID(Integer userOrganizeID) {
+        this.userOrganizeID = userOrganizeID;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public String getBalanceType() {
+        return balanceType;
+    }
+
+    public void setBalanceType(String balanceType) {
+        this.balanceType = balanceType;
+    }
+
+    public Date getAddDate() {
+        return addDate;
+    }
+
+    public void setAddDate(Date addDate) {
+        this.addDate = addDate;
+    }
+
+    public String getAmount() {
+        return amount;
+    }
+
+    public void setAmount(String amount) {
+        this.amount = amount;
+    }
+
+    public Integer getOrderId() {
+        return orderId;
+    }
+
+    public void setOrderId(Integer orderId) {
+        this.orderId = orderId;
+    }
+
+    public Integer getReceiptId() {
+        return receiptId;
+    }
+
+    public void setReceiptId(Integer receiptId) {
+        this.receiptId = receiptId;
+    }
+
+    public Integer getReturnedId() {
+        return returnedId;
+    }
+
+    public void setReturnedId(Integer returnedId) {
+        this.returnedId = returnedId;
+    }
+
+    public Integer getWithdrawalsId() {
+        return withdrawalsId;
+    }
+
+    public void setWithdrawalsId(Integer withdrawalsId) {
+        this.withdrawalsId = withdrawalsId;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public String getAbleUserMoney() {
+        return ableUserMoney;
+    }
+
+    public void setAbleUserMoney(String ableUserMoney) {
+        this.ableUserMoney = ableUserMoney;
+    }
+
+    public String getStartTime() {
+        return startTime;
+    }
+
+    public void setStartTime(String startTime) {
+        this.startTime = startTime;
+    }
+
+    public String getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(String endTime) {
+        this.endTime = endTime;
+    }
+}

+ 62 - 0
src/main/java/com/caimei/entity/Province.java

@@ -0,0 +1,62 @@
+package com.caimei.entity;
+
+
+import java.io.Serializable;
+import java.util.List;
+
+public class Province implements Serializable {
+    private Long provinceid;
+    private String name;        //名称
+    private String validflag;   //是否可用,1可用
+    private Float deliveryfee;  //运费
+    private Float freemintotalprice;  //最低包邮金额
+    private List<City> citys;    //下面的市
+
+    public Long getProvinceid() {
+        return provinceid;
+    }
+
+    public void setProvinceid(Long provinceid) {
+        this.provinceid = provinceid;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getValidflag() {
+        return validflag;
+    }
+
+    public void setValidflag(String validflag) {
+        this.validflag = validflag;
+    }
+
+    public Float getDeliveryfee() {
+        return deliveryfee;
+    }
+
+    public void setDeliveryfee(Float deliveryfee) {
+        this.deliveryfee = deliveryfee;
+    }
+
+    public Float getFreemintotalprice() {
+        return freemintotalprice;
+    }
+
+    public void setFreemintotalprice(Float freemintotalprice) {
+        this.freemintotalprice = freemintotalprice;
+    }
+
+    public List<City> getCitys() {
+        return citys;
+    }
+
+    public void setCitys(List<City> citys) {
+        this.citys = citys;
+    }
+}

+ 58 - 0
src/main/java/com/caimei/entity/Town.java

@@ -0,0 +1,58 @@
+package com.caimei.entity;
+
+public class Town {
+    private Integer townid; //
+    private Integer cityid;  //所在城市Id
+    private String name;  //名称
+    private String zip;     //邮编
+    private String telzip;  //电话区号
+    private String validflag;   //是否可用,1可用
+
+    public Integer getTownid() {
+        return townid;
+    }
+
+    public void setTownid(Integer townid) {
+        this.townid = townid;
+    }
+
+    public Integer getCityid() {
+        return cityid;
+    }
+
+    public void setCityid(Integer cityid) {
+        this.cityid = cityid;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getZip() {
+        return zip;
+    }
+
+    public void setZip(String zip) {
+        this.zip = zip;
+    }
+
+    public String getTelzip() {
+        return telzip;
+    }
+
+    public void setTelzip(String telzip) {
+        this.telzip = telzip;
+    }
+
+    public String getValidflag() {
+        return validflag;
+    }
+
+    public void setValidflag(String validflag) {
+        this.validflag = validflag;
+    }
+}

+ 2 - 2
src/main/java/com/caimei/entity/WxJsonModel.java

@@ -4,7 +4,7 @@ import com.alibaba.fastjson.JSONObject;
 
 import java.io.Serializable;
 
-public class WxJsonModel implements Serializable {
+public class WxJsonModel implements Serializable{
 	
 	private static final long serialVersionUID = 1L;
 	
@@ -93,4 +93,4 @@ public class WxJsonModel implements Serializable {
 		return JSONObject.toJSONString(this);
 	}
 	
-}
+}

+ 19 - 0
src/main/java/com/caimei/mapper/user/LoginMapper.java

@@ -0,0 +1,19 @@
+package com.caimei.mapper.user;
+
+import com.caimei.entity.CmOperationUser;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+@Mapper
+public interface LoginMapper {
+
+    CmOperationUser doLogin(@Param("openid") String openid, @Param("userOrganizeID") Integer userOrganizeID);
+
+    CmOperationUser isEnabled(@Param("invitationCode") String invitationCode, @Param("userOrganizeID") Integer userOrganizeID);
+
+    void update(CmOperationUser operationUser);
+
+    CmOperationUser query(CmOperationUser operationUser);
+
+    void updateOperationUser(CmOperationUser user);
+}

+ 34 - 0
src/main/java/com/caimei/mapper/user/PersonalMapper.java

@@ -0,0 +1,34 @@
+package com.caimei.mapper.user;
+
+import com.caimei.entity.*;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+@Mapper
+public interface PersonalMapper {
+
+    Club myCentre(CmOperationUser operationUser);
+
+    List<CmUserBalanceRecord> touchBalance(CmUserBalanceRecord balanceRecord);
+
+    List<Province> findAllProvince();
+
+    List<City> findAllCity(Long provinceid);
+
+    List<Town> findAllTown(Integer cityid);
+
+    List<Address> findAddress(Integer userID);
+
+    Address findCantonal(Integer townID);
+
+    void saveAddress(Address address);
+
+    void updateAddress(Address address);
+
+    void deleteAddress(Integer addressID);
+
+    Address findDefaultAddress(Integer userID);
+
+    Integer ableUserMoney(Integer userId);
+}

+ 12 - 0
src/main/java/com/caimei/service/user/LoginService.java

@@ -0,0 +1,12 @@
+package com.caimei.service.user;
+
+import com.caimei.entity.CmOperationUser;
+
+public interface LoginService {
+
+    CmOperationUser doLogin(String openid, Integer userOrganizeID);
+
+    CmOperationUser isEnabled(String invitationCode, Integer userOrganizeID);
+
+    void update(CmOperationUser operationUser);
+}

+ 26 - 0
src/main/java/com/caimei/service/user/PersonalService.java

@@ -0,0 +1,26 @@
+package com.caimei.service.user;
+
+import com.caimei.entity.*;
+
+import java.util.List;
+import java.util.Map;
+
+public interface PersonalService {
+    Club myCentre(CmOperationUser operationUser);
+
+    Map<String, Object> touchBalance(Integer index, Integer pageSize, int year, int month, CmUserBalanceRecord balanceRecord);
+
+    List<Province> address();
+
+    List<Address> findAddress(Integer userID);
+
+    List<Province> getProvince();
+
+    List<City> getCity(Long provinceid);
+
+    List<Town> getTown(Integer cityid);
+
+    void saveAddress(Address address);
+
+    void deleteAddress(Integer addressID);
+}

+ 45 - 0
src/main/java/com/caimei/service/user/impl/LoginServiceImpl.java

@@ -0,0 +1,45 @@
+package com.caimei.service.user.impl;
+
+import com.caimei.entity.CmOperationUser;
+import com.caimei.mapper.user.LoginMapper;
+import com.caimei.service.user.LoginService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+
+@Service
+public class LoginServiceImpl implements LoginService {
+    @Autowired
+    private LoginMapper loginMapper;
+
+    @Override
+    public CmOperationUser doLogin(String openid, Integer userOrganizeID) {
+        CmOperationUser operationUser = loginMapper.doLogin(openid, userOrganizeID);
+        return operationUser;
+    }
+
+    @Override
+    public CmOperationUser isEnabled(String invitationCode, Integer userOrganizeID) {
+        CmOperationUser operationUser = loginMapper.isEnabled(invitationCode, userOrganizeID);
+        return operationUser;
+    }
+
+    @Override
+    public void update(CmOperationUser operationUser) {
+        CmOperationUser user = loginMapper.query(operationUser);
+        //判断是否存在已下线的会所用户
+        if (user != null) {
+            user.setOpenid("");
+            user.setLinkName("");
+            user.setDelFlag("1");
+            user.setStatus("1");
+            user.setUpdateTime(new Date());
+            loginMapper.updateOperationUser(user);
+        }
+        operationUser.setStatus("2");
+        operationUser.setBindTime(new Date());
+        operationUser.setUpdateTime(new Date());
+        loginMapper.update(operationUser);
+    }
+}

+ 116 - 0
src/main/java/com/caimei/service/user/impl/PersonalServiceImpl.java

@@ -0,0 +1,116 @@
+package com.caimei.service.user.impl;
+
+import com.caimei.entity.*;
+import com.caimei.mapper.user.PersonalMapper;
+import com.caimei.service.user.PersonalService;
+import com.github.pagehelper.PageHelper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class PersonalServiceImpl implements PersonalService {
+    @Autowired
+    private PersonalMapper personalMapper;
+
+    @Override
+    public Club myCentre(CmOperationUser operationUser) {
+        return personalMapper.myCentre(operationUser);
+    }
+
+    @Override
+    public Map<String, Object> touchBalance(Integer index, Integer pageSize, int year, int month, CmUserBalanceRecord balanceRecord) {
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(Calendar.YEAR, year);
+        calendar.set(Calendar.MONTH, month - 1);
+        calendar.set(Calendar.DAY_OF_MONTH, calendar.getMinimum(Calendar.DATE));
+        String startTime = format.format(calendar.getTime()) + " 00:00:00";
+        balanceRecord.setStartTime(startTime);
+        calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DATE));
+        String endTime = format.format(calendar.getTime()) + " 23:59:59";
+        balanceRecord.setEndTime(endTime);
+        if (index == null) index = 1;
+        if (pageSize == null) pageSize = 10;
+        PageHelper.startPage(index, pageSize);
+        List<CmUserBalanceRecord> list = personalMapper.touchBalance(balanceRecord);
+        Page<CmUserBalanceRecord> page = new Page<>(list);
+        Integer ableUserMoney = personalMapper.ableUserMoney(balanceRecord.getUserId());
+        Map<String, Object> map = new HashMap();
+        map.put("page", page);
+        map.put("ableUserMoney", ableUserMoney);
+        return map;
+    }
+
+    @Override
+    public List<Province> address() {
+        List<Province> list = personalMapper.findAllProvince();
+        for (Province province : list) {
+            List<City> cityList = personalMapper.findAllCity(province.getProvinceid());
+            province.setCitys(cityList);
+            if (cityList != null && cityList.size() > 0) {
+                for (City city : cityList) {
+                    List<Town> townList = personalMapper.findAllTown(city.getCityid());
+                    city.setTowns(townList);
+                }
+            }
+        }
+        return list;
+    }
+
+    @Override
+    public List<Address> findAddress(Integer userID) {
+        List<Address> addressList = personalMapper.findAddress(userID);
+        for (Address address : addressList) {
+            Address cantonal = personalMapper.findCantonal(address.getTownID());
+            address.setProvince(cantonal.getProvince());
+            address.setCity(cantonal.getCity());
+            address.setTown(cantonal.getTown());
+        }
+        return addressList;
+    }
+
+    @Override
+    public List<Province> getProvince() {
+        List<Province> list = personalMapper.findAllProvince();
+        return list;
+    }
+
+    @Override
+    public List<City> getCity(Long provinceid) {
+        return personalMapper.findAllCity(provinceid);
+    }
+
+    @Override
+    public List<Town> getTown(Integer cityid) {
+        return personalMapper.findAllTown(cityid);
+    }
+
+    @Override
+    public void saveAddress(Address address) {
+        if (address.getDefaultFlag() != null && address.getDefaultFlag().equals("1")) {
+            Address addr = personalMapper.findDefaultAddress(address.getUserID());
+            if (addr != null) {
+                addr.setDefaultFlag("0");
+                personalMapper.updateAddress(addr);
+            }
+        }
+        if (address.getAddressID() == null) {
+            personalMapper.saveAddress(address);
+        } else {
+            personalMapper.updateAddress(address);
+        }
+    }
+
+    @Override
+    public void deleteAddress(Integer addressID) {
+        personalMapper.deleteAddress(addressID);
+    }
+
+
+}

+ 240 - 0
src/main/java/com/caimei/utils/HttpRequest.java

@@ -0,0 +1,240 @@
+package com.caimei.utils;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * HTTP 请求工具
+ */
+public class HttpRequest {
+    /**
+     * 向指定URL发送GET方法的请求
+     *
+     * @param url   发送请求的URL
+     * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
+     * @return URL 所代表远程资源的响应结果
+     * @throws Exception
+     */
+    @SuppressWarnings("unused")
+    public static String sendGetWithParameter(String url, String param) throws Exception {
+        StringBuffer result=new StringBuffer();
+        BufferedReader in = null;
+        try {
+            String urlNameString = url + "?" + param;
+            URL realUrl = new URL(urlNameString);
+            // 打开和URL之间的连接
+            URLConnection connection = realUrl.openConnection();
+            // 设置通用的请求属性
+            connection.setRequestProperty("accept", "*/*");
+            connection.setRequestProperty("connection", "Keep-Alive");
+            connection.setRequestProperty("Accept-Charset", "utf-8");
+            connection.setRequestProperty("contentType", "utf-8");
+            connection.setConnectTimeout(5000);
+            // 建立实际的连接
+            connection.connect();
+            // 获取所有响应头字段
+            Map<String, List<String>> map = connection.getHeaderFields();
+            // 遍历所有的响应头字段
+            for (String key : map.keySet()) {
+                // System.out.println(key + "--->" + map.get(key)); //关闭响应头的输出
+            }
+            // 定义 BufferedReader输入流来读取URL的响应
+            in = new BufferedReader(new InputStreamReader(
+                    connection.getInputStream()));
+            String line;
+            while ((line = in.readLine()) != null) {
+                result.append(line);
+            }
+        } catch (Exception e) {
+            throw e;
+        }
+        // 使用finally块来关闭输入流
+        finally {
+            try {
+                if (in != null) {
+                    in.close();
+                }
+            } catch (Exception e2) {
+                throw e2;
+            }
+        }
+        return result.toString();
+    }
+
+
+    @SuppressWarnings("unused")
+    public static String sendGet(String url) throws Exception {
+        StringBuffer result=new StringBuffer();
+        BufferedReader in = null;
+        try {
+
+            URL realUrl = new URL(url);
+            // 打开和URL之间的连接
+            URLConnection connection = realUrl.openConnection();
+            // 设置通用的请求属性
+            connection.setRequestProperty("accept", "*/*");
+            connection.setRequestProperty("connection", "Keep-Alive");
+            connection.setRequestProperty("Accept-Charset", "utf-8");
+            connection.setRequestProperty("contentType", "utf-8");
+            connection.setConnectTimeout(5000);
+            // 建立实际的连接
+            connection.connect();
+            // 获取所有响应头字段
+            Map<String, List<String>> map = connection.getHeaderFields();
+            // 遍历所有的响应头字段
+            for (String key : map.keySet()) {
+                //  System.out.println(key + "--->" + map.get(key));
+            }
+            // 定义 BufferedReader输入流来读取URL的响应
+            in = new BufferedReader(new InputStreamReader(
+                    connection.getInputStream()));
+            String line;
+            while ((line = in.readLine()) != null) {
+                result.append(line);
+            }
+        } catch (Exception e) {
+            throw e;
+        }
+        // 使用finally块来关闭输入流
+        finally {
+            try {
+                if (in != null) {
+                    in.close();
+                }
+            } catch (Exception e2) {
+                throw e2;
+            }
+        }
+        return result.toString();
+    }
+
+    /**
+     * 向指定 URL 发送POST方法的请求
+     *
+     * @param url   发送请求的 URL
+     * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
+     * @return 所代表远程资源的响应结果
+     * @throws Exception
+     */
+    public static String sendPost(String url, String param) throws Exception {
+        PrintWriter out = null;
+        BufferedReader in = null;
+        StringBuffer result=new StringBuffer();
+        try {
+            URL realUrl = new URL(url);
+            // 打开和URL之间的连接
+            URLConnection conn = realUrl.openConnection();
+            // 设置通用的请求属性
+            conn.setRequestProperty("accept", "*/*");
+            conn.setRequestProperty("connection", "Keep-Alive");
+            conn.setRequestProperty("Accept-Charset", "utf-8");
+            conn.setRequestProperty("contentType", "utf-8");
+            conn.setConnectTimeout(5000);
+            // 发送POST请求必须设置如下两行
+            conn.setDoOutput(true);
+            conn.setDoInput(true);
+            // 获取URLConnection对象对应的输出流
+            out = new PrintWriter(conn.getOutputStream());
+            // 发送请求参数
+            out.print(param);
+            // flush输出流的缓冲
+            out.flush();
+            // 定义BufferedReader输入流来读取URL的响应
+            in = new BufferedReader(
+                    new InputStreamReader(conn.getInputStream()));
+            String line;
+            while ((line = in.readLine()) != null) {
+                result.append(line);
+            }
+        } catch (Exception e) {
+            throw e;
+        }
+        //使用finally块来关闭输出流、输入流
+        finally {
+            try {
+                if (out != null) {
+                    out.close();
+                }
+                if (in != null) {
+                    in.close();
+                }
+            } catch (Exception ex) {
+                throw ex;
+            }
+        }
+        return result.toString();
+    }
+
+
+    /**
+     * 向指定 URL 发送POST方法的请求
+     *
+     * @param url 发送请求的 URL
+     * @param paramMap 请求参数
+     * @return 所代表远程资源的响应结果
+     */
+    public static String sendPost(String url, Map<String, ?> paramMap) throws Exception{
+        PrintWriter out = null;
+        BufferedReader in = null;
+        String result = "";
+
+        String param = "";
+        Iterator<String> it = paramMap.keySet().iterator();
+
+        while(it.hasNext()) {
+            String key = it.next();
+            param += key + "=" + paramMap.get(key) + "&";
+        }
+
+        try {
+            URL realUrl = new URL(url);
+            // 打开和URL之间的连接
+            URLConnection conn = realUrl.openConnection();
+            // 设置通用的请求属性
+            conn.setRequestProperty("accept", "*/*");
+            conn.setRequestProperty("connection", "Keep-Alive");
+            conn.setRequestProperty("Accept-Charset", "utf-8");
+            conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
+            // 发送POST请求必须设置如下两行
+            conn.setDoOutput(true);
+            conn.setDoInput(true);
+            // 获取URLConnection对象对应的输出流
+            out = new PrintWriter(conn.getOutputStream());
+            // 发送请求参数
+            out.print(param);
+            // flush输出流的缓冲
+            out.flush();
+            // 定义BufferedReader输入流来读取URL的响应
+            in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
+            String line;
+            while ((line = in.readLine()) != null) {
+                result += line;
+            }
+        } catch (Exception e) {
+            throw e;
+        }
+        //使用finally块来关闭输出流、输入流
+        finally{
+            try{
+                if(out!=null){
+                    out.close();
+                }
+                if(in!=null){
+                    in.close();
+                }
+            }
+            catch(IOException ex){
+               throw ex;
+            }
+        }
+        return result;
+    }
+
+}

+ 4 - 3
src/main/resources/dev/application-dev.yml

@@ -37,8 +37,9 @@ pagehelper:
 
 #日志配置
 logging:
-  file: E:/brand-alliance/catalina.out
+  file: E:/caimei-mall/catalina.out
   level: debug
 
-miniprogramAppId:
-miniprogramAppSecret:
+miniprogram:
+  AppId: wxd3cadbba8bf55f47
+  AppSecret: 811a6ab8105e0bdf24cd78f6e6f009a7

+ 71 - 0
src/main/resources/mapper/LoginMapper.xml

@@ -0,0 +1,71 @@
+<?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.caimei.mapper.user.LoginMapper">
+    <select id="doLogin" resultType="com.caimei.entity.CmOperationUser">
+        SELECT
+          cou.*
+        FROM
+          cm_operation_user cou
+          LEFT JOIN USER u ON u.userID = cou.userID
+        WHERE
+          cou.openid = #{openid}
+          AND cou.userOrganizeID = #{userOrganizeID}
+          AND cou.delFlag = '0'
+          AND u.clubStatus = '90'
+    </select>
+
+    <select id="isEnabled" resultType="com.caimei.entity.CmOperationUser">
+        SELECT
+          cou.*,
+          u.clubStatus
+        FROM
+          cm_operation_user cou
+          LEFT JOIN USER u ON u.userID = cou.userID
+        WHERE
+          cou.invitationCode = #{invitationCode}
+          AND cou.userOrganizeID = #{userOrganizeID}
+    </select>
+
+    <update id="update" parameterType="com.caimei.entity.CmOperationUser">
+        UPDATE
+          cm_operation_user
+        SET
+          nickName = #{nickName},
+          openid = #{openid},
+          bindTime = #{bindTime},
+          status = #{status}
+        WHERE
+          invitationCode = #{invitationCode}
+          AND userOrganizeID = #{userOrganizeID}
+          AND delFlag = '0'
+    </update>
+
+    <update id="updateOperationUser" parameterType="com.caimei.entity.CmOperationUser">
+        UPDATE
+          cm_operation_user
+        SET
+          nickName = #{nickName},
+          openid = #{openid},
+          bindTime = #{bindTime},
+          status = #{status},
+          delFlag = #{delFlag}
+        WHERE
+          openid = #{openid}
+          AND userOrganizeID = #{userOrganizeID}
+    </update>
+
+    <select id="query" parameterType="com.caimei.entity.CmOperationUser" resultType="com.caimei.entity.CmOperationUser">
+        SELECT
+          cou.*
+        FROM
+          cm_operation_user cou
+          LEFT JOIN USER u ON u.userID = cou.userID
+        WHERE
+          cou.openid = #{openid}
+          AND cou.userOrganizeID = #{userOrganizeID}
+          AND cou.delFlag = '0'
+          AND u.clubStatus = '91'
+    </select>
+</mapper>

+ 141 - 0
src/main/resources/mapper/PersonalMapper.xml

@@ -0,0 +1,141 @@
+<?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.caimei.mapper.user.PersonalMapper">
+    <select id="myCentre" parameterType="com.caimei.entity.CmOperationUser" resultType="com.caimei.entity.Club">
+        SELECT
+          c.name,
+          c.userID,
+          c.clubID,
+          c.headpic,
+          u.ableUserMoney,
+          cuo.contactNumber,
+          cuo.introduction
+        FROM
+          cm_operation_user cou
+          LEFT JOIN USER u ON u.userID = cou.userID
+          LEFT JOIN club c ON u.clubID = c.clubID
+          LEFT JOIN cm_user_organize cuo ON cuo.id=cou.userOrganizeID
+        WHERE
+          cou.openid = #{openid}
+          AND cou.userOrganizeID = #{userOrganizeID}
+          AND cou.delFlag = '0'
+    </select>
+
+    <select id="touchBalance" resultType="com.caimei.entity.CmUserBalanceRecord">
+        SELECT
+        cubr.*
+        FROM
+        cm_user_balance_record cubr
+        <where>
+            <if test="balanceType != null and balanceType != ''">
+                AND cubr.balanceType = #{balanceType}
+            </if>
+            AND cubr.addDate <![CDATA[ >= ]]> #{startTime}
+            AND cubr.addDate <![CDATA[ <= ]]> #{endTime}
+            AND cubr.userId = #{userId}
+            AND cubr.delFlag = '0'
+        </where>
+        ORDER BY cubr.addDate DESC
+    </select>
+
+    <select id="ableUserMoney" resultType="int">
+        SELECT ableUserMoney FROM USER WHERE userID = #{userID}
+    </select>
+
+    <select id="findAllProvince" resultType="com.caimei.entity.Province">
+        SELECT * FROM province WHERE validFlag = '1'
+    </select>
+
+    <select id="findAllCity" resultType="com.caimei.entity.City">
+        SELECT * FROM city WHERE provinceID = #{provinceID} AND validFlag = '1'
+    </select>
+
+    <select id="findAllTown" resultType="com.caimei.entity.Town">
+        SELECT * FROM town WHERE cityID = #{cityID} AND validFlag = '1'
+    </select>
+
+    <select id="findAddress" resultType="com.caimei.entity.Address">
+        SELECT
+          addressID,
+          userID,
+          shouHuoRen,
+          townID,
+          address AS addressDetail,
+          postalCode,
+          phone,
+          mobile,
+          defaultFlag
+        FROM
+          address
+        WHERE
+          userID = #{userID}
+        ORDER BY
+          defaultFlag DESC,
+          addressID ASC
+    </select>
+
+    <select id="findCantonal" resultType="com.caimei.entity.Address">
+        SELECT
+          p.name AS province,
+          c.name AS city,
+          t.name AS town
+        FROM
+          town t
+          LEFT JOIN city c ON t.cityID = c.cityID
+          LEFT JOIN province p ON p.provinceID = c.provinceID
+        WHERE
+          t.townID = #{townID}
+          AND t.validFlag = '1'
+          AND c.validFlag = '1'
+          AND p.validFlag = '1'
+    </select>
+
+    <insert id="saveAddress" parameterType="com.caimei.entity.Address">
+        INSERT INTO address (
+          userID, shouHuoRen, townID, address,
+          mobile, defaultFlag
+        )
+        VALUES
+          (
+            #{userID},#{shouHuoRen},#{townID},
+            #{addressDetail},#{mobile},#{defaultFlag}
+          )
+    </insert>
+
+    <update id="updateAddress" parameterType="com.caimei.entity.Address">
+        UPDATE
+          address
+        SET
+          shouHuoRen =#{shouHuoRen},
+          townID = #{townID},
+          address = #{addressDetail},
+          mobile = #{mobile},
+          defaultFlag = #{defaultFlag}
+        WHERE
+          addressID = #{addressID}
+    </update>
+
+    <delete id="deleteAddress" parameterType="int">
+        DELETE FROM address WHERE addressID = #{addressID} 
+    </delete>
+
+    <select id="findDefaultAddress" resultType="com.caimei.entity.Address">
+        SELECT
+          addressID,
+          userID,
+          shouHuoRen,
+          townID,
+          address AS addressDetail,
+          postalCode,
+          phone,
+          mobile,
+          defaultFlag
+        FROM
+          address
+        WHERE
+          userID = #{userID}
+          AND defaultFlag = '1'
+    </select>
+</mapper>

+ 4 - 3
src/main/resources/prod/application-prod.yml

@@ -39,8 +39,9 @@ pagehelper:
 
 #日志配置
 logging:
-  file: /mnt/newdatadrive/data/runtime/tomcat-instance/caimei-brand-alliance/catalina.out
+  file: /mnt/newdatadrive/data/runtime/tomcat-instance/caimei-mall/catalina.out
   level: debug
 
-miniprogramAppId:
-miniprogramAppSecret:
+miniprogram:
+  AppId: wxd3cadbba8bf55f47
+  AppSecret: 811a6ab8105e0bdf24cd78f6e6f009a7

+ 1 - 1
src/main/resources/public/index.html

@@ -1,6 +1,6 @@
 <!DOCTYPE html>
 <html>
-<title>采美365网-正品联盟</title>
+<title>采美365网-星范商城</title>
 <meta charset="UTF-8">
 <meta http-equiv="pragma" content="no-cache">
 <meta http-equiv="cache-control" content="no-cache">

+ 4 - 3
src/main/resources/test/application-test.yml

@@ -38,8 +38,9 @@ pagehelper:
 
 #日志配置
 logging:
-  file: /mnt/newdatadrive/data/runtime/tomcat-instance/caimei-brand-alliance/catalina.out
+  file: /mnt/newdatadrive/data/runtime/tomcat-instance/caimei-mall/catalina.out
   level: debug
 
-miniprogramAppId:
-miniprogramAppSecret:
+miniprogram:
+  AppId: wxd3cadbba8bf55f47
+  AppSecret: 811a6ab8105e0bdf24cd78f6e6f009a7