|
|
|
@ -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.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.stereotype.Controller;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
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 javax.annotation.Resource;
|
|
|
|
@ -16,40 +22,25 @@ import javax.annotation.Resource;
|
|
|
|
|
/**
|
|
|
|
|
* Created by yixian on 2017-04-28.
|
|
|
|
|
*/
|
|
|
|
|
@Controller
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("/act/encourage_money")
|
|
|
|
|
public class EncourageMoneyController {
|
|
|
|
|
Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
|
@Resource
|
|
|
|
|
private EncourageService encourageService;
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/orders/{orderId}", method = RequestMethod.GET)
|
|
|
|
|
public ModelAndView takeEncourageMoney(@PathVariable String orderId,@RequestHeader("User-Agent") String ua) {
|
|
|
|
|
ua = ua.toLowerCase();
|
|
|
|
|
if (ua.contains("micromessenger")) {
|
|
|
|
|
return new ModelAndView("redirect:/act/encourage_money/orders/" + orderId + "/wechat");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (ua.contains("alipayclient")) {
|
|
|
|
|
return new ModelAndView("redirect:/act/encourage_money/orders/" + orderId + "/alipay");
|
|
|
|
|
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");
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@WechatMapping(value = "/orders/{orderId}/wechat", method = RequestMethod.GET)
|
|
|
|
|
public JSONObject takeEncourageMoneyWeChat(@PathVariable String orderId, @ModelAttribute(CommonConsts.WECHATINFO) JSONObject wxUser) {
|
|
|
|
|
if (wxUser == null) {
|
|
|
|
|
if(StringUtils.isEmpty(user_id)){
|
|
|
|
|
return new JSONObject();
|
|
|
|
|
}
|
|
|
|
|
return encourageService.takeEncourageMoney(orderId, wxUser.getString("openid"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@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"));
|
|
|
|
|
return encourageService.takeEncourageMoney(orderId, user_id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/orders/{orderId}/crit", method = RequestMethod.PUT)
|
|
|
|
@ -57,21 +48,27 @@ public class EncourageMoneyController {
|
|
|
|
|
return encourageService.doubleEncourageMoney(orderId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@WechatMapping(value = "/my", method = RequestMethod.GET, oauthType = WxOauthType.USERINFO)
|
|
|
|
|
public ModelAndView encourageLogs(@ModelAttribute(CommonConsts.WECHATINFO) JSONObject wxUser) {
|
|
|
|
|
@RequestMapping(value = "/my", method = RequestMethod.GET)
|
|
|
|
|
public ModelAndView encourageLogs(@ModelAttribute(CommonConsts.WECHATINFO) JSONObject wxUser,@ModelAttribute(CommonConsts.ALIUSER) JSONObject aliuser) {
|
|
|
|
|
ModelAndView mav = new ModelAndView("activity/encourage_money/my");
|
|
|
|
|
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);
|
|
|
|
|
return mav;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@WechatMapping(value = "/desc",method = RequestMethod.GET)
|
|
|
|
|
@RequestMapping(value = "/desc",method = RequestMethod.GET)
|
|
|
|
|
public ModelAndView descPage(){
|
|
|
|
|
return new ModelAndView("activity/encourage_money/desc");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@WechatMapping(value = "/merchants",method = RequestMethod.GET)
|
|
|
|
|
@RequestMapping(value = "/merchants",method = RequestMethod.GET)
|
|
|
|
|
public ModelAndView merchantsPage(){
|
|
|
|
|
return new ModelAndView("activity/encourage_money/merchants");
|
|
|
|
|
}
|
|
|
|
|