master
kira 8 years ago
parent bd7786e40f
commit 735aaadc27

@ -8,12 +8,12 @@ import au.com.royalpay.payment.tools.permission.wechat.WechatMapping;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
@ -31,20 +31,21 @@ public class EncourageMoneyController {
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")) { if(StringUtils.isEmpty(user_id)){
return new ModelAndView("redirect:/act/encourage_money/orders/" + orderId + "/alipay"); return new JSONObject();
} }
return null; return encourageService.takeEncourageMoney(orderId, user_id);
} }
@WechatMapping(value = "/orders/{orderId}/wechat", method = RequestMethod.GET) @RequestMapping(value = "/orders/{orderId}/wechat", method = RequestMethod.GET)
public JSONObject takeEncourageMoneyWeChat(@PathVariable String orderId, @ModelAttribute(CommonConsts.WECHATINFO) JSONObject wxUser) { public JSONObject takeEncourageMoneyWeChat(@PathVariable String orderId, @ModelAttribute(CommonConsts.WECHATINFO) JSONObject wxUser) {
logger.info("kiratest---wechat"); logger.info("kiratest---wechat");
if (wxUser == null) { if (wxUser == null) {

Loading…
Cancel
Save