|
@@ -853,6 +853,234 @@ public class OrderController extends BaseController {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * 清洗机器人支付成功回调
|
|
|
|
+ *
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @RequestMapping(value = "/payCleanNotifyTest", method = RequestMethod.GET)
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public Object payCleanNotifyTest( ) {
|
|
|
|
+
|
|
|
|
+ String r6_Status = "r6_Status";
|
|
|
|
+
|
|
|
|
+ // 订单号
|
|
|
|
+ String sn = "050328220200418115647";
|
|
|
|
+ Order order = orderService.findBySn(sn);
|
|
|
|
+ Equipment byClientId = equipmentService.findByClientId(order.getClientId());
|
|
|
|
+ List<Price> priceList = priceService.findAll();
|
|
|
|
+ Double dayPrice = null;
|
|
|
|
+ Double timesPrice = null;
|
|
|
|
+ for(Price price:priceList){
|
|
|
|
+ if(price.getName().equals("dayPay")){
|
|
|
|
+ dayPrice = price.getPrice();
|
|
|
|
+ }
|
|
|
|
+ if(price.getName().equals("timesPay")){
|
|
|
|
+ timesPrice = price.getPrice();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(order.getProductName().equals("按天数购买")){
|
|
|
|
+ BigDecimal price = order.getPrice();
|
|
|
|
+ BigDecimal pri = BigDecimal.valueOf(dayPrice);
|
|
|
|
+ BigDecimal number = price.divide(pri);
|
|
|
|
+// String s = number.toString();
|
|
|
|
+// String[] split = s.split(".");
|
|
|
|
+// String day = split[0];
|
|
|
|
+ int dayNumber = number.intValue();
|
|
|
|
+ String overdueDate = byClientId.getOverdueDate();
|
|
|
|
+ if(overdueDate!=null&&overdueDate.length()>1){
|
|
|
|
+ //续费
|
|
|
|
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
+ Date date = null;
|
|
|
|
+ try {
|
|
|
|
+ date= formatter.parse(overdueDate);
|
|
|
|
+ long time = date.getTime();
|
|
|
|
+ long dayN = dayNumber*24*3600*1000;
|
|
|
|
+ long finalTime = time + dayN;
|
|
|
|
+ Date dates = new Date(finalTime);
|
|
|
|
+ String dateString = formatter.format(dates);
|
|
|
|
+ byClientId.setOverdueDate(dateString);
|
|
|
|
+// equipmentService.update(byClientId);
|
|
|
|
+ } catch (ParseException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ //首次充值
|
|
|
|
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
+ Date date = new Date();
|
|
|
|
+ try {
|
|
|
|
+ long time = date.getTime();
|
|
|
|
+ long dayN = dayNumber*24*3600*1000;
|
|
|
|
+ long finalTime = time + dayN;
|
|
|
|
+ Date dates = new Date(finalTime);
|
|
|
|
+ String dateString = formatter.format(dates);
|
|
|
|
+ byClientId.setOverdueDate(dateString);
|
|
|
|
+// equipmentService.update(byClientId);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ if(order.getProductName().equals("按次数购买")){
|
|
|
|
+ BigDecimal price = order.getPrice();
|
|
|
|
+ BigDecimal pri = BigDecimal.valueOf(timesPrice);
|
|
|
|
+ BigDecimal number = price.divide(pri);
|
|
|
|
+ String remaining = byClientId.getRemaining();
|
|
|
|
+ if(remaining!=null&&remaining.length()>0){
|
|
|
|
+ BigDecimal rmain = BigDecimal.valueOf(Double.valueOf(remaining));
|
|
|
|
+ BigDecimal remian = rmain.add(number);
|
|
|
|
+ int value = remian.intValue();
|
|
|
|
+ byClientId.setRemaining(String.valueOf(value));
|
|
|
|
+ equipmentService.update(byClientId);
|
|
|
|
+ }else{
|
|
|
|
+ int value = number.intValue();
|
|
|
|
+ byClientId.setRemaining(String.valueOf(value));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ String gtClientId = byClientId.getGtClientId();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return "success";
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 清洗机器人支付成功回调
|
|
|
|
+ *
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @RequestMapping(value = "/payCleanNotify", method = RequestMethod.GET)
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public Object payCleanNotify(HttpServletRequest request) {
|
|
|
|
+
|
|
|
|
+ String r6_Status = request.getParameter("r6_Status");
|
|
|
|
+
|
|
|
|
+ // 订单号
|
|
|
|
+ String sn = request.getParameter("r2_OrderNo");
|
|
|
|
+ Order order = orderService.findBySn(sn);
|
|
|
|
+ if(order.getStatus()!=Order.Status.unpay){
|
|
|
|
+ return "success";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(JoinpayConstant.r6_Status_100.equals(r6_Status)){
|
|
|
|
+
|
|
|
|
+ // 已支付
|
|
|
|
+ order.setStatus(Order.Status.pay);
|
|
|
|
+
|
|
|
|
+ // 支付平台产生的流水号
|
|
|
|
+ String r7_TrxNo = request.getParameter("r7_TrxNo");
|
|
|
|
+ order.setTrxNo(r7_TrxNo);
|
|
|
|
+
|
|
|
|
+ // 格式:YYYY-MM-DD HH:mm:ss
|
|
|
|
+ String ra_PayTime = request.getParameter("ra_PayTime");
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
+ Date payDate = sdf.parse(URLDecoder.decode(ra_PayTime, "UTF-8"));
|
|
|
|
+ order.setPayDate(payDate);
|
|
|
|
+ } catch (ParseException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
|
+
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ orderService.update(order);
|
|
|
|
+
|
|
|
|
+ JSONObject kindData = new JSONObject();
|
|
|
|
+ kindData.put("sn" , order.getSn());
|
|
|
|
+ kindData.put("productName" , order.getProductName());
|
|
|
|
+
|
|
|
|
+ Equipment byClientId = equipmentService.findByClientId(order.getClientId());
|
|
|
|
+ List<Price> priceList = priceService.findAll();
|
|
|
|
+ Double dayPrice = null;
|
|
|
|
+ Double timesPrice = null;
|
|
|
|
+ for(Price price:priceList){
|
|
|
|
+ if(price.getName().equals("dayPay")){
|
|
|
|
+ dayPrice = price.getPrice();
|
|
|
|
+ }
|
|
|
|
+ if(price.getName().equals("timesPay")){
|
|
|
|
+ timesPrice = price.getPrice();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(order.getProductName().equals("按天数购买")){
|
|
|
|
+ BigDecimal price = order.getPrice();
|
|
|
|
+ BigDecimal pri = BigDecimal.valueOf(dayPrice);
|
|
|
|
+ BigDecimal number = price.divide(pri);
|
|
|
|
+// String s = number.toString();
|
|
|
|
+// String[] split = s.split(".");
|
|
|
|
+// int value = number.intValue();
|
|
|
|
+// String day = String.valueOf(value);
|
|
|
|
+ int dayNumber = number.intValue();
|
|
|
|
+ String overdueDate = byClientId.getOverdueDate();
|
|
|
|
+ if(overdueDate!=null&&overdueDate.length()>1){
|
|
|
|
+ //续费
|
|
|
|
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
+ Date date = null;
|
|
|
|
+ try {
|
|
|
|
+ date= formatter.parse(overdueDate);
|
|
|
|
+ long time = date.getTime();
|
|
|
|
+ long dayN = dayNumber*24*3600*1000;
|
|
|
|
+ long finalTime = time + dayN;
|
|
|
|
+ Date dates = new Date(finalTime);
|
|
|
|
+ String dateString = formatter.format(dates);
|
|
|
|
+ byClientId.setOverdueDate(dateString);
|
|
|
|
+ equipmentService.update(byClientId);
|
|
|
|
+ } catch (ParseException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ //首次充值
|
|
|
|
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
+ Date date = new Date();
|
|
|
|
+ try {
|
|
|
|
+ long time = date.getTime();
|
|
|
|
+ long dayN = dayNumber*24*3600*1000;
|
|
|
|
+ long finalTime = time + dayN;
|
|
|
|
+ Date dates = new Date(finalTime);
|
|
|
|
+ String dateString = formatter.format(dates);
|
|
|
|
+ byClientId.setOverdueDate(dateString);
|
|
|
|
+ equipmentService.update(byClientId);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ if(order.getProductName().equals("按次数购买")){
|
|
|
|
+ BigDecimal price = order.getPrice();
|
|
|
|
+ BigDecimal pri = BigDecimal.valueOf(timesPrice);
|
|
|
|
+ BigDecimal number = price.divide(pri);
|
|
|
|
+ String remaining = byClientId.getRemaining();
|
|
|
|
+ if(remaining!=null&&remaining.length()>0){
|
|
|
|
+ BigDecimal rmain = BigDecimal.valueOf(Double.valueOf(remaining));
|
|
|
|
+ BigDecimal remian = rmain.add(number);
|
|
|
|
+ int value = remian.intValue();
|
|
|
|
+ byClientId.setRemaining(String.valueOf(value));
|
|
|
|
+ equipmentService.update(byClientId);
|
|
|
|
+ }else{
|
|
|
|
+ int value = number.intValue();
|
|
|
|
+ byClientId.setRemaining(String.valueOf(value));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ String gtClientId = byClientId.getGtClientId();
|
|
|
|
+
|
|
|
|
+// PushUtils.push(gtClientId, "支付成功", "您的订单支付成功", PushUtils.buildJson("pay_success", kindData.toString()).toString());
|
|
|
|
+// PushUtils.push(equipmentService.findByClientId(order.getClientId()).getGtClientId(), "支付成功", "您的订单支付成功", PushUtils.buildJson("pay_success", kindData.toString()).toString());
|
|
|
|
+ order.setNote(gtClientId+"已推送");
|
|
|
|
+ orderService.update(order);
|
|
|
|
+ return "success";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return "success";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
* 优惠码支付成功回调
|
|
* 优惠码支付成功回调
|
|
*
|
|
*
|
|
* @return
|
|
* @return
|