| 
					
				 | 
			
			
				@@ -4,6 +4,8 @@ import cn.binarywang.wx.miniapp.api.WxMaService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.binarywang.wx.miniapp.bean.WxMaUserInfo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.alibaba.fastjson.JSON; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.alibaba.fastjson.JSONArray; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.github.binarywang.wxpay.constant.WxPayConstants; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -22,6 +24,11 @@ import com.hcloud.microserver.commoncore.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.hcloud.microserver.h5.facade.carbon.entity.CustomerInfo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.hcloud.microserver.h5.facade.carbon.forms.CustomerInfoForm; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.hcloud.microserver.h5.facade.carbon.vo.MyWxMpUser; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.hcloud.microserver.h5.service.CustomerService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import io.swagger.annotations.Api; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import io.swagger.annotations.ApiImplicitParam; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import io.swagger.annotations.ApiImplicitParams; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import io.swagger.annotations.ApiOperation; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import lombok.extern.slf4j.Slf4j; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import me.chanjar.weixin.common.error.WxErrorException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.apache.commons.lang.StringUtils; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -48,6 +55,7 @@ import java.util.concurrent.TimeUnit; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Slf4j 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Controller 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @RequestMapping("/wechat/app") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+@Api(description = "微信小程序api服务") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 public class WechatAppController extends BaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private final Logger logger = LoggerFactory.getLogger(this.getClass()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -58,9 +66,11 @@ public class WechatAppController extends BaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private CustomerInfoService customerInfoService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * 登陆接口 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @ApiOperation(value = "微信登录", notes = "微信登录") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @PostMapping("/login") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @ResponseBody 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public ResponseBase login(@RequestBody LoginRequest request) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -76,8 +86,7 @@ public class WechatAppController extends BaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 解密用户信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             WxMaUserInfo wxUserInfo = wxMaService.getUserService().getUserInfo(session.getSessionKey(), request.getEncryptedData(), request.getIv()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            //解密手机号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            WxMaPhoneNumberInfo phoneNoInfo = wxMaService.getUserService().getPhoneNoInfo(session.getSessionKey(), request.getEncryptedData(), request.getIv()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (null == wxUserInfo) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 throw new RuntimeException("wxUser not exist"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -88,7 +97,6 @@ public class WechatAppController extends BaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             myWxMpUser.setNickname(wxUserInfo.getNickName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             myWxMpUser.setHeadImgUrl(wxUserInfo.getAvatarUrl()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             myWxMpUser.setSex(Integer.parseInt(wxUserInfo.getGender())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            myWxMpUser.setPhone(phoneNoInfo.getPhoneNumber()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             //后台新增用户成功 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             Map<String, String> tokenMap = customerInfoService.wxlogin(myWxMpUser); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             //登录系统获取本地 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -99,16 +107,31 @@ public class WechatAppController extends BaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private CustomerService customerService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * 登陆接口 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @PostMapping("/login/test") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @ApiOperation(value = "小程序绑定手机号", notes = "小程序绑定手机号") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @PostMapping("/login/phone") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @ResponseBody 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public ResponseBase login(@RequestBody MyWxMpUser myWxMpUser) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //后台新增用户成功 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Map<String, String> tokenMap = customerInfoService.wxlogin(myWxMpUser); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public ResponseBase loginphone(@RequestBody LoginRequest request) throws WxErrorException { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 获取微信用户session 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        WxMaJscode2SessionResult session = wxMaService.getUserService().getSessionInfo(request.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //解密手机号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        WxMaPhoneNumberInfo phoneNoInfo = wxMaService.getUserService().getPhoneNoInfo(session.getSessionKey(), request.getEncryptedData(), request.getIv()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        CustomerInfo customerInfo = new CustomerInfo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        CustomerInfoForm tokenUser = customerService.getCurrentMember(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        customerInfo.setGuid(tokenUser.getGuid()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        customerInfo.setPhone(phoneNoInfo.getPhoneNumber()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int i = customerInfoService.updateByPrimaryKeySelective(customerInfo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (i == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return resultVOError(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //登录系统获取本地 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return resultVOSuccess(tokenMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return resultVOSuccess(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private Map<String, Object> getStringObjectMap(String customerId) { 
			 |