|
@@ -3,17 +3,26 @@ package com.iamberry.wechat.handles.apparatus;
|
|
|
import com.iamberry.wechat.core.entity.PageBean;
|
|
|
import com.iamberry.wechat.core.entity.ResultMsg;
|
|
|
import com.iamberry.wechat.core.entity.WechatUtils;
|
|
|
+import com.iamberry.wechat.core.entity.admin.ShopSystemRule;
|
|
|
import com.iamberry.wechat.core.entity.apparatus.Apparatus;
|
|
|
import com.iamberry.wechat.core.entity.member.Member;
|
|
|
+import com.iamberry.wechat.face.admin.SystemService;
|
|
|
import com.iamberry.wechat.face.apparatus.ApparatusService;
|
|
|
+import com.iamberry.wechat.tools.HttpClient431Util;
|
|
|
+import com.iamberry.wechat.tools.NameUtils;
|
|
|
import com.iamberry.wechat.tools.ResultInfo;
|
|
|
+import com.iamberry.wechat.tools.payUtil.StringUtil;
|
|
|
+import net.sf.json.JSONObject;
|
|
|
+import org.apache.commons.lang3.StringEscapeUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
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.List;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* Created by liuzhiwei on 2017/12/28.
|
|
@@ -24,6 +33,8 @@ public class ApparatusHandler {
|
|
|
|
|
|
@Autowired
|
|
|
private ApparatusService apparatusService;
|
|
|
+ @Autowired
|
|
|
+ private SystemService systemService;
|
|
|
|
|
|
/**
|
|
|
* 分页查询用户机器信息
|
|
@@ -33,6 +44,7 @@ public class ApparatusHandler {
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
+ @ResponseBody
|
|
|
@RequestMapping("/select_apparatus_page")
|
|
|
public ResultMsg selectApparatusPage(HttpServletRequest request,
|
|
|
@RequestParam(value = "pageNO", defaultValue = "1", required = false) int pageNO,
|
|
@@ -53,4 +65,65 @@ public class ApparatusHandler {
|
|
|
msg.setStatus(true);
|
|
|
return msg;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 注册会员
|
|
|
+ * @param request
|
|
|
+ * @param member
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @ResponseBody
|
|
|
+ @RequestMapping("add_apparatus")
|
|
|
+ public ResultMsg addApparatus(HttpServletRequest request,Member member) throws Exception {
|
|
|
+ ResultMsg msg = new ResultMsg();
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ Member memberInfo = WechatUtils.getUserBySession(request);
|
|
|
+ //获取换新时间期限
|
|
|
+ ShopSystemRule renewRule = systemService.selectOneShopRuleById(246);
|
|
|
+ member.setUserOpenid(memberInfo.getUserOpenid());
|
|
|
+ //获取二维码中机器条形码
|
|
|
+ String barCode = request.getParameter("barCode");
|
|
|
+ String buyDate = request.getParameter("buyDate");
|
|
|
+ String storeId = request.getParameter("storeId");
|
|
|
+
|
|
|
+ if (!StringUtil.isNotEmpty(barCode)) {
|
|
|
+ msg.setResultCode(ResultInfo.ERRORCODE);
|
|
|
+ msg.setStatus(false);
|
|
|
+ msg.setMessage("机器条形码为空,请重新扫描二维码!");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
+ Apparatus apparatus = new Apparatus();
|
|
|
+ apparatus.setApparatusStatus(1);
|
|
|
+ apparatus.setApparatusBarcode(barCode);
|
|
|
+ //获取机器信息
|
|
|
+ List<Apparatus> apparatusList = apparatusService.listApparatusPage(apparatus);
|
|
|
+ if (apparatusList != null && apparatusList.size() > 0) {
|
|
|
+ msg.setResultCode(ResultInfo.ERRORCODE);
|
|
|
+ msg.setStatus(false);
|
|
|
+ msg.setMessage("机器条形码为空,请重新扫描二维码!");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ apparatus.setUserOpenid(memberInfo.getUserOpenid());
|
|
|
+ apparatus.setApparatusBuyDate(format.parse(buyDate));
|
|
|
+ apparatus.setApparatusWarrantyDate(updateDate(format.parse(buyDate),renewRule.getRuleNum().intValue()));
|
|
|
+ apparatus.setStoreId(Integer.getInteger(storeId));
|
|
|
+
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改日期 增加月
|
|
|
+ * @param date
|
|
|
+ * @param month
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public Date updateDate(Date date,int month) throws Exception {
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(date);
|
|
|
+ calendar.add(Calendar.MONTH, month);
|
|
|
+ return calendar.getTime();
|
|
|
+ }
|
|
|
}
|