|
|
|
@ -3,9 +3,19 @@ package au.com.royalpay.payment.manage.customers.web;
|
|
|
|
|
import au.com.royalpay.payment.manage.customers.core.EncourageService;
|
|
|
|
|
import au.com.royalpay.payment.tools.CommonConsts;
|
|
|
|
|
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 com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
|
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.servlet.ModelAndView;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
@ -13,38 +23,46 @@ import javax.annotation.Resource;
|
|
|
|
|
/**
|
|
|
|
|
* Created by yixian on 2017-04-28.
|
|
|
|
|
*/
|
|
|
|
|
@RestController
|
|
|
|
|
@Controller
|
|
|
|
|
@RequestMapping("/act/encourage_money")
|
|
|
|
|
public class EncourageMoneyController {
|
|
|
|
|
Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
|
@Resource
|
|
|
|
|
private EncourageService encourageService;
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/orders/{orderId}", method = RequestMethod.PUT)
|
|
|
|
|
public String takeEncourageMoney(@PathVariable String orderId,@RequestHeader("User-Agent") String ua) {
|
|
|
|
|
ua = ua.toLowerCase();
|
|
|
|
|
if (ua.contains("micromessenger")) {
|
|
|
|
|
return "redirect:/act/encourage_money/orders/" + orderId + "/wechat";
|
|
|
|
|
@RequestMapping(value = "/orders/{orderId}", method = RequestMethod.GET)
|
|
|
|
|
public JSONObject takeEncourageMoney(@PathVariable String orderId,@ModelAttribute(CommonConsts.WECHATINFO) JSONObject wxUser,@ModelAttribute(CommonConsts.ALIUSER) JSONObject aliuser) {
|
|
|
|
|
String user_id = "";
|
|
|
|
|
if(wxUser==null){
|
|
|
|
|
user_id = aliuser.getString("user_id");
|
|
|
|
|
}else {
|
|
|
|
|
user_id = wxUser.getString("openid");
|
|
|
|
|
}
|
|
|
|
|
if (ua.contains("alipayclient")) {
|
|
|
|
|
return "redirect:/act/encourage_money/orders/" + orderId + "/alipay";
|
|
|
|
|
if(StringUtils.isEmpty(user_id)){
|
|
|
|
|
return new JSONObject();
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
return encourageService.takeEncourageMoney(orderId, user_id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/orders/{orderId}/wechat", method = RequestMethod.PUT)
|
|
|
|
|
@RequestMapping(value = "/orders/{orderId}/wechat", method = RequestMethod.GET)
|
|
|
|
|
public JSONObject takeEncourageMoneyWeChat(@PathVariable String orderId, @ModelAttribute(CommonConsts.WECHATINFO) JSONObject wxUser) {
|
|
|
|
|
logger.info("kiratest---wechat");
|
|
|
|
|
if (wxUser == null) {
|
|
|
|
|
return new JSONObject();
|
|
|
|
|
}
|
|
|
|
|
logger.info(wxUser.toJSONString());
|
|
|
|
|
return encourageService.takeEncourageMoney(orderId, wxUser.getString("openid"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/orders/{orderId}/alipay", method = RequestMethod.PUT)
|
|
|
|
|
@AlipayMapping(value = "/orders/{orderId}/alipay", method = RequestMethod.GET)
|
|
|
|
|
public JSONObject takeEncourageMoneyAlipay(@PathVariable String orderId, @ModelAttribute(CommonConsts.ALIUSER) JSONObject alipayInfo) {
|
|
|
|
|
logger.info("kiratest---alipay");
|
|
|
|
|
|
|
|
|
|
if (alipayInfo == null) {
|
|
|
|
|
return new JSONObject();
|
|
|
|
|
}
|
|
|
|
|
logger.info(alipayInfo.toJSONString());
|
|
|
|
|
return encourageService.takeEncourageMoney(orderId, alipayInfo.getString("user_id"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|