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

# Conflicts:
#	src/main/java/au/com/royalpay/payment/manage/actchairty/core/impls/ActChairtyServiceImp.java
master
eason 6 years ago
commit 7c064c70d8

@ -17,8 +17,6 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
@ -68,48 +66,48 @@ public class ActChairtyServiceImp implements ActChairtyService {
List<JSONObject> result = new ArrayList<>(); List<JSONObject> result = new ArrayList<>();
List<JSONObject> getAnalysis = actChairtyMapper.getChairtyWeekAnalysis(params.getDate("begin"), params.getDate("end")); List<JSONObject> getAnalysis = actChairtyMapper.getChairtyWeekAnalysis(params.getDate("begin"), params.getDate("end"));
DateFormatUtils df = new DateFormatUtils(); DateFormatUtils df = new DateFormatUtils();
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
cal.setTime(params.getDate("begin")); cal.setTime(params.getDate("begin"));
cal.add(cal.DAY_OF_MONTH, -1); cal.add(cal.DAY_OF_MONTH, -1);
long beginTime = params.getDate("begin").getTime(); long beginTime = params.getDate("begin").getTime();
long endTime = params.getDate("end").getTime(); long endTime = params.getDate("end").getTime();
long betweenDays = (long)((endTime - beginTime) / (1000 * 60 * 60 *24)); long betweenDays = (long)((endTime - beginTime) / (1000 * 60 * 60 *24));
List<String> weekStart = new ArrayList<>(); List<String> weekStart = new ArrayList<>();
for(int i=0;i<=betweenDays;i++){ for(int i=0;i<=betweenDays;i++){
cal.add(cal.DAY_OF_MONTH, 1);//DATE=日 cal.add(cal.DAY_OF_MONTH, 1);//DATE=日
if ((cal.get(Calendar.DAY_OF_WEEK)) == 2) { if ((cal.get(Calendar.DAY_OF_WEEK)) == 2) {
weekStart.add(df.format(cal.getTime(),"yyyy-MM-dd")); weekStart.add(df.format(cal.getTime(),"yyyy-MM-dd"));
}
} }
} for(int i=0;i<weekStart.size();i++){
for(int i=0;i<weekStart.size();i++){ JSONObject weekDay = new JSONObject();
JSONObject weekDay = new JSONObject(); BigDecimal count_ordernum = new BigDecimal(0);
BigDecimal count_ordernum = new BigDecimal(0); BigDecimal sum_ordernum = new BigDecimal(0);
BigDecimal sum_ordernum = new BigDecimal(0); String weekS = weekStart.get(i);
String weekS = weekStart.get(i); try {
try { Date dateStar = DateUtils.parseDate(weekS,"yyyy-MM-dd");
Date dateStar = DateUtils.parseDate(weekS,"yyyy-MM-dd"); Date dateEnd = DateUtils.addDays(dateStar, 7);
Date dateEnd = DateUtils.addDays(dateStar, 7); for (int b = 0; b < getAnalysis.size(); b++) {
for (int b = 0; b < getAnalysis.size(); b++) { long orderDate = getAnalysis.get(b).getDate("orderdate").getTime();
long orderDate = getAnalysis.get(b).getDate("orderdate").getTime(); if (orderDate >= dateStar.getTime() && orderDate < dateEnd.getTime()) {
if (orderDate >= dateStar.getTime() && orderDate < dateEnd.getTime()) { count_ordernum = count_ordernum.add(getAnalysis.get(b).getBigDecimal("count_ordernum"));
count_ordernum = count_ordernum.add(getAnalysis.get(b).getBigDecimal("count_ordernum")); sum_ordernum = sum_ordernum.add(getAnalysis.get(b).getBigDecimal("sum_ordernum"));
sum_ordernum = sum_ordernum.add(getAnalysis.get(b).getBigDecimal("sum_ordernum")); }
} }
} BigDecimal chairty = new BigDecimal(0.01);
BigDecimal chairty = new BigDecimal(0.01); BigDecimal chairty_amount = count_ordernum.multiply(chairty);
BigDecimal chairty_amount = count_ordernum.multiply(chairty); BigDecimal f1 = sum_ordernum.setScale(2, BigDecimal.ROUND_HALF_UP);
BigDecimal f1 = sum_ordernum.setScale(2, BigDecimal.ROUND_HALF_UP); BigDecimal f2 = chairty_amount.setScale(2, BigDecimal.ROUND_HALF_UP);
BigDecimal f2 = chairty_amount.setScale(2, BigDecimal.ROUND_HALF_UP); weekDay.put("weekstart", weekStart.get(i));
weekDay.put("weekstart", weekStart.get(i)); weekDay.put("count_ordernum", count_ordernum);
weekDay.put("count_ordernum", count_ordernum); weekDay.put("sum_ordernum", f1);
weekDay.put("sum_ordernum", f1); weekDay.put("chairty_amount",f2 );
weekDay.put("chairty_amount",f2 ); result.add(weekDay);
result.add(weekDay); } catch (Exception e) {
} catch (Exception e) { logger.info("Act_Chairty Error:",e);
logger.info("Act_Chairty Error:",e);
}
} }
}
return result; return result;
} }

@ -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.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.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 org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -13,38 +23,46 @@ import javax.annotation.Resource;
/** /**
* Created by yixian on 2017-04-28. * Created by yixian on 2017-04-28.
*/ */
@RestController @Controller
@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.PUT) @RequestMapping(value = "/orders/{orderId}", method = RequestMethod.GET)
public String 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 "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 "redirect:/act/encourage_money/orders/" + orderId + "/alipay"; 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) { public JSONObject takeEncourageMoneyWeChat(@PathVariable String orderId, @ModelAttribute(CommonConsts.WECHATINFO) JSONObject wxUser) {
logger.info("kiratest---wechat");
if (wxUser == null) { if (wxUser == null) {
return new JSONObject(); return new JSONObject();
} }
logger.info(wxUser.toJSONString());
return encourageService.takeEncourageMoney(orderId, wxUser.getString("openid")); 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) { public JSONObject takeEncourageMoneyAlipay(@PathVariable String orderId, @ModelAttribute(CommonConsts.ALIUSER) JSONObject alipayInfo) {
logger.info("kiratest---alipay");
if (alipayInfo == null) { if (alipayInfo == null) {
return new JSONObject(); return new JSONObject();
} }
logger.info(alipayInfo.toJSONString());
return encourageService.takeEncourageMoney(orderId, alipayInfo.getString("user_id")); return encourageService.takeEncourageMoney(orderId, alipayInfo.getString("user_id"));
} }

@ -33,7 +33,7 @@ $(function () {
function loadEncourage() { function loadEncourage() {
$.ajax({ $.ajax({
url: '/act/encourage_money/orders/' + window.order_id, url: '/act/encourage_money/orders/' + window.order_id,
method: 'PUT', method: 'GET',
dataType: 'json', dataType: 'json',
success: function (encourage) { success: function (encourage) {
if (encourage.access_amount) { if (encourage.access_amount) {

Loading…
Cancel
Save