Merge remote-tracking branch 'master/develop' into develop

master
luoyang14z7 6 years ago
commit 9e8f4f0b08

@ -3,12 +3,18 @@ package au.com.royalpay.payment.manage.customers.web;
import au.com.royalpay.payment.manage.customers.core.EncourageService; import au.com.royalpay.payment.manage.customers.core.EncourageService;
import au.com.royalpay.payment.tools.CommonConsts; import au.com.royalpay.payment.tools.CommonConsts;
import au.com.royalpay.payment.tools.connections.mpsupport.beans.WxOauthType; import au.com.royalpay.payment.tools.connections.mpsupport.beans.WxOauthType;
import au.com.royalpay.payment.tools.permission.alipay.AlipayMapping;
import au.com.royalpay.payment.tools.permission.wechat.WechatMapping; import au.com.royalpay.payment.tools.permission.wechat.WechatMapping;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Controller; import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -16,40 +22,25 @@ import javax.annotation.Resource;
/** /**
* Created by yixian on 2017-04-28. * Created by yixian on 2017-04-28.
*/ */
@Controller @RestController
@RequestMapping("/act/encourage_money") @RequestMapping("/act/encourage_money")
public class EncourageMoneyController { public class EncourageMoneyController {
Logger logger = LoggerFactory.getLogger(getClass());
@Resource @Resource
private EncourageService encourageService; private EncourageService encourageService;
@RequestMapping(value = "/orders/{orderId}", method = RequestMethod.GET) @RequestMapping(value = "/orders/{orderId}", method = RequestMethod.GET)
public ModelAndView takeEncourageMoney(@PathVariable String orderId,@RequestHeader("User-Agent") String ua) { public JSONObject takeEncourageMoney(@PathVariable String orderId,@ModelAttribute(CommonConsts.WECHATINFO) JSONObject wxUser,@ModelAttribute(CommonConsts.ALIUSER) JSONObject aliuser) {
ua = ua.toLowerCase(); String user_id = "";
if (ua.contains("micromessenger")) { if(wxUser==null){
return new ModelAndView("redirect:/act/encourage_money/orders/" + orderId + "/wechat"); user_id = aliuser.getString("user_id");
}else {
} user_id = wxUser.getString("openid");
if (ua.contains("alipayclient")) {
return new ModelAndView("redirect:/act/encourage_money/orders/" + orderId + "/alipay");
} }
return null; if(StringUtils.isEmpty(user_id)){
}
@WechatMapping(value = "/orders/{orderId}/wechat", method = RequestMethod.GET)
public JSONObject takeEncourageMoneyWeChat(@PathVariable String orderId, @ModelAttribute(CommonConsts.WECHATINFO) JSONObject wxUser) {
if (wxUser == null) {
return new JSONObject(); return new JSONObject();
} }
return encourageService.takeEncourageMoney(orderId, wxUser.getString("openid")); return encourageService.takeEncourageMoney(orderId, user_id);
}
@AlipayMapping(value = "/orders/{orderId}/alipay", method = RequestMethod.GET)
public JSONObject takeEncourageMoneyAlipay(@PathVariable String orderId, @ModelAttribute(CommonConsts.ALIUSER) JSONObject alipayInfo) {
if (alipayInfo == null) {
return new JSONObject();
}
return encourageService.takeEncourageMoney(orderId, alipayInfo.getString("user_id"));
} }
@RequestMapping(value = "/orders/{orderId}/crit", method = RequestMethod.PUT) @RequestMapping(value = "/orders/{orderId}/crit", method = RequestMethod.PUT)
@ -57,21 +48,27 @@ public class EncourageMoneyController {
return encourageService.doubleEncourageMoney(orderId); return encourageService.doubleEncourageMoney(orderId);
} }
@WechatMapping(value = "/my", method = RequestMethod.GET, oauthType = WxOauthType.USERINFO) @RequestMapping(value = "/my", method = RequestMethod.GET)
public ModelAndView encourageLogs(@ModelAttribute(CommonConsts.WECHATINFO) JSONObject wxUser) { public ModelAndView encourageLogs(@ModelAttribute(CommonConsts.WECHATINFO) JSONObject wxUser,@ModelAttribute(CommonConsts.ALIUSER) JSONObject aliuser) {
ModelAndView mav = new ModelAndView("activity/encourage_money/my"); ModelAndView mav = new ModelAndView("activity/encourage_money/my");
mav.addObject("wxUser", wxUser); mav.addObject("wxUser", wxUser);
JSONObject balanceStatus = encourageService.getBalanceStatus(wxUser.getString("openid")); String user_id = "";
if(wxUser==null){
user_id = aliuser.getString("user_id");
}else {
user_id = wxUser.getString("openid");
}
JSONObject balanceStatus = encourageService.getBalanceStatus(user_id);
mav.addObject("balance_status", balanceStatus); mav.addObject("balance_status", balanceStatus);
return mav; return mav;
} }
@WechatMapping(value = "/desc",method = RequestMethod.GET) @RequestMapping(value = "/desc",method = RequestMethod.GET)
public ModelAndView descPage(){ public ModelAndView descPage(){
return new ModelAndView("activity/encourage_money/desc"); return new ModelAndView("activity/encourage_money/desc");
} }
@WechatMapping(value = "/merchants",method = RequestMethod.GET) @RequestMapping(value = "/merchants",method = RequestMethod.GET)
public ModelAndView merchantsPage(){ public ModelAndView merchantsPage(){
return new ModelAndView("activity/encourage_money/merchants"); return new ModelAndView("activity/encourage_money/merchants");
} }

Loading…
Cancel
Save