ソースを参照

修改有些客户不能看到统计数据的BUG

李天标 5 年 前
コミット
bc571d39ed

+ 6 - 0
app-api/pom.xml

@@ -12,6 +12,12 @@
 
     <artifactId>app-api</artifactId>
     <dependencies>
+<!--         paytm支付-->
+        <dependency>
+            <groupId>myjar</groupId>
+            <artifactId>PaytmChecksum</artifactId>
+            <version>1.1</version>
+        </dependency>
         <dependency>
             <groupId>com.hboxs</groupId>
             <artifactId>app-common</artifactId>

+ 115 - 0
app-api/src/main/java/com/hboxs/control/api/order/CoinOrderController.java

@@ -10,14 +10,23 @@ import com.hboxs.entity.CoinOrder;
 import com.hboxs.service.AdminService;
 import com.hboxs.service.CoinOrderService;
 import com.hboxs.service.EquipmentService;
+import com.paytm.pg.merchant.CheckSumServiceHelper;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
+import java.io.BufferedReader;
+import java.io.DataOutputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.math.BigDecimal;
+import java.net.HttpURLConnection;
+import java.net.URL;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 
 @Controller("apiCoinOrderController")
@@ -41,6 +50,112 @@ public class CoinOrderController extends BaseController {
         System.out.println("email....");
         return SUCCESS_MESSAGE;
     }
+
+    @RequestMapping(value = "/email2", method = RequestMethod.POST)
+    @ResponseBody
+    public Message email2(String toEmail, String subject, String content) {
+        /* initialize an object */
+        JSONObject paytmParams = new JSONObject();
+
+        /* body parameters */
+        JSONObject body = new JSONObject();
+        if(subject.equals("SMS")){
+            body.put("sendSms", true);
+        }else{
+            body.put("sendEmail", true);
+        }
+        Double amount = 0.10;
+        body.put("amount", amount);
+        /* Find your MID in your Paytm Dashboard at https://dashboard.paytm.com/next/apikeys */
+        JSONObject customerContact = new JSONObject();
+        customerContact.put("customerEmail", "520283710@qq.com");
+        customerContact.put("customerMobile", "9910215225");
+        body.put("customerContact", customerContact);
+        body.put("statusCallbackUrl", "http://app.sunzee.com.cn/api/order/paytmNotify.htm");
+        body.put("mid", "WorldP64425807474247");
+
+        /* Possible value are "GENERIC", "FIXED", "INVOICE" */
+        body.put("linkType", "LINK_TYPE");
+
+        /* Enter your choice of payment link description here, special characters are not allowed */
+        body.put("linkDescription", "PAYMENT LINK DESCRIPTION");
+
+        /* Enter your choice of payment link name here, special characters and spaces are not allowed */
+        body.put("linkName", "PAYMENTLINKNAME");
+        String result = "";
+/**
+ * Generate checksum by parameters we have in body
+ * You can get Checksum JAR from https://developer.paytm.com/docs/v1/payment-gateway/#code
+ * Find your Merchant Key in your Paytm Dashboard at https://dashboard.paytm.com/next/apikeys
+ */
+        String checksum2="";
+        Map<String,String> map = new HashMap<>();
+
+        try {
+
+
+            String checksum = CheckSumServiceHelper.getCheckSumServiceHelper().genrateCheckSum("kbzk1DSbJiV_O3p5", body.toString());
+            checksum2 = checksum;
+            map.put("checksum2",checksum2);
+            /* head parameters */
+            JSONObject head = new JSONObject();
+            Long startTs = System.currentTimeMillis(); // 当前时间戳
+            /* This will be AES */
+            Long yiu=new Long(9000l);
+            Long cd=new Long(startTs);
+            Long d=cd-yiu;
+//            Long time = startTs-yiu;‬
+            head.put("timestamp", d);
+            head.put("tokenType", "AES");
+
+            /* put generated checksum value here */
+            head.put("signature", checksum);
+
+            /* prepare JSON string for request */
+            paytmParams.put("body", body);
+            paytmParams.put("head", head);
+            String post_data = paytmParams.toString();
+
+            /* for Staging */
+            URL url = new URL("https://securegw-stage.paytm.in/link/create");
+
+            /* for Production */
+// URL url = new URL("https://securegw.paytm.in/link/create);
+            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+            connection.setRequestMethod("POST");
+            connection.setRequestProperty("Content-Type", "application/json");
+            connection.setDoOutput(true);
+
+            DataOutputStream requestWriter = new DataOutputStream(connection.getOutputStream());
+            requestWriter.writeBytes(post_data);
+            requestWriter.close();
+            String responseData = "";
+            InputStream is = connection.getInputStream();
+            BufferedReader responseReader = new BufferedReader(new InputStreamReader(is));
+            map.put("1","1");
+            if ((responseData = responseReader.readLine()) != null) {
+                result=responseData;
+                System.out.append("Response: " + responseData);
+            }
+            // System.out.append("Request: " + post_data);
+            responseReader.close();
+        } catch (Exception exception) {
+            exception.printStackTrace();
+        }
+
+        if(result.length()>240){
+            map.put("result",result.substring(0,240));
+        }else {
+            map.put("result",result);
+        }
+
+
+        content = map.toString();
+        new MailUtil().send(toEmail,subject,content);
+        System.out.println("email....");
+        return SUCCESS_MESSAGE;
+    }
+
     /**添加线下
      * @param coinOrderVo
      * @return

+ 151 - 0
app-api/src/main/java/com/hboxs/control/api/order/OrderController.java

@@ -11,8 +11,12 @@ import com.hboxs.entity.*;
 import com.hboxs.entity.Order;
 import com.hboxs.joinpay.entity.Mch;
 import com.hboxs.service.*;
+import com.paytm.pg.merchant.CheckSumServiceHelper;
 import org.apache.commons.lang.StringUtils;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.ResponseBody;
@@ -53,6 +57,153 @@ public class OrderController extends BaseController {
     @Resource(name = "priceServiceImpl")
     private PriceService priceService;
 
+
+    /**
+     * 印度paytm支付
+     * @param
+     * @return
+     */
+    @GetMapping("/paytmpay")
+    public Map<String,String> paytmpay( String type ) {
+        /* initialize an object */
+        JSONObject paytmParams = new JSONObject();
+
+        /* body parameters */
+        JSONObject body = new JSONObject();
+        if(type.equals("SMS")){
+            body.put("sendSms", true);
+        }else{
+            body.put("sendEmail", true);
+        }
+        Double amount = 0.10;
+        body.put("amount", amount);
+        /* Find your MID in your Paytm Dashboard at https://dashboard.paytm.com/next/apikeys */
+        JSONObject customerContact = new JSONObject();
+        customerContact.put("customerEmail", "520283710@qq.com");
+        customerContact.put("customerMobile", "9910215225");
+        body.put("customerContact", customerContact);
+        body.put("statusCallbackUrl", "http://app.sunzee.com.cn/api/order/paytmNotify.htm");
+        body.put("mid", "WorldP64425807474247");
+
+        /* Possible value are "GENERIC", "FIXED", "INVOICE" */
+        body.put("linkType", "LINK_TYPE");
+
+        /* Enter your choice of payment link description here, special characters are not allowed */
+        body.put("linkDescription", "PAYMENT LINK DESCRIPTION");
+
+        /* Enter your choice of payment link name here, special characters and spaces are not allowed */
+        body.put("linkName", "PAYMENTLINKNAME");
+        String result = "";
+/**
+ * Generate checksum by parameters we have in body
+ * You can get Checksum JAR from https://developer.paytm.com/docs/v1/payment-gateway/#code
+ * Find your Merchant Key in your Paytm Dashboard at https://dashboard.paytm.com/next/apikeys
+ */
+        String checksum2="";
+        try {
+            String checksum = CheckSumServiceHelper.getCheckSumServiceHelper().genrateCheckSum("kbzk1DSbJiV_O3p5", body.toString());
+
+            /* head parameters */
+            JSONObject head = new JSONObject();
+            Long startTs = System.currentTimeMillis(); // 当前时间戳
+            /* This will be AES */
+            Long yiu=new Long(9000l);
+            Long cd=new Long(startTs);
+            Long d=cd-yiu;
+//            Long time = startTs-yiu;‬
+            head.put("timestamp", d);
+            head.put("tokenType", "AES");
+
+            /* put generated checksum value here */
+            head.put("signature", checksum);
+
+            /* prepare JSON string for request */
+            paytmParams.put("body", body);
+            paytmParams.put("head", head);
+            String post_data = paytmParams.toString();
+
+            /* for Staging */
+            URL url = new URL("https://securegw-stage.paytm.in/link/create");
+
+            /* for Production */
+// URL url = new URL("https://securegw.paytm.in/link/create);
+            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+            connection.setRequestMethod("POST");
+            connection.setRequestProperty("Content-Type", "application/json");
+            connection.setDoOutput(true);
+
+            DataOutputStream requestWriter = new DataOutputStream(connection.getOutputStream());
+            requestWriter.writeBytes(post_data);
+            requestWriter.close();
+            String responseData = "";
+            InputStream is = connection.getInputStream();
+            BufferedReader responseReader = new BufferedReader(new InputStreamReader(is));
+            checksum2 = checksum;
+            if ((responseData = responseReader.readLine()) != null) {
+                result=responseData;
+                System.out.append("Response: " + responseData);
+            }
+            // System.out.append("Request: " + post_data);
+            responseReader.close();
+        } catch (Exception exception) {
+            exception.printStackTrace();
+        }
+        Map<String,String> map = new HashMap<>();
+        if(result.length()>240){
+            map.put("result",result.substring(0,240));
+        }else {
+            map.put("result",result);
+        }
+
+        map.put("checksum2",checksum2);
+        return map;
+    }
+    /**
+     * 支付成功回调
+     *
+     * @return
+     */
+    @RequestMapping(value = "/paytmNotify", method = RequestMethod.GET)
+    @ResponseBody
+    public Object refunda(HttpServletRequest request) {
+
+//        String r6_Status = request.getParameter("r6_Status");
+        try {String paytmChecksum = null;
+
+            /* Create a TreeMap from the parameters received in POST */
+            TreeMap<String, String> paytmParams = new TreeMap<String, String>();
+            for (Map.Entry<String, String[]> requestParamsEntry : request.getParameterMap().entrySet()) {
+                if ("CHECKSUMHASH".equalsIgnoreCase(requestParamsEntry.getKey())){
+                    paytmChecksum = requestParamsEntry.getValue()[0];
+                } else {
+                    paytmParams.put(requestParamsEntry.getKey(), requestParamsEntry.getValue()[0]);
+                }
+
+            }
+            PromoCode promoCode = new PromoCode();
+            promoCode.setUseBy(paytmParams.toString().substring(0,240));
+            promoCode.setUserName(paytmChecksum);
+            promoCode.setCreateDate(new Date());
+            promoCode.setModifyDate(new Date());
+            promoCodeService.save(promoCode);
+
+/**
+ * Verify checksum
+ * Find your Merchant Key in your Paytm Dashboard at https://dashboard.paytm.com/next/apikeys
+ */
+            boolean isValidChecksum = CheckSumServiceHelper.getCheckSumServiceHelper().verifycheckSum("kbzk1DSbJiV_O3p5", paytmParams, paytmChecksum);
+            if (isValidChecksum) {
+                System.out.append("Checksum Matched");
+            } else {
+                System.out.append("Checksum Mismatched");
+            }
+        } catch (Exception exception) {
+            exception.printStackTrace();
+        }
+
+        return "success";
+    }
+
     /**
      * 请求在线支付
      *

+ 2 - 1
app-backend-web/src/main/java/com/hboxs/control/admin/OrderStatisticsController.java

@@ -282,7 +282,8 @@ public class OrderStatisticsController extends BaseController {
         List<Admin> admins = adminService.findAllLowerAdmin(admin.getId());
         Long[] lowerIds = new Long[1];
         for (Admin admin1 : admins) {
-            if (admin1.getId() == AdminUtils.decrypt(false, managerId)) {
+//            if (admin1.getId() == AdminUtils.decrypt(false, managerId)) {
+            if (admin1.getId().equals(AdminUtils.decrypt(false, managerId))) {
                 Long id = admin1.getId();
                 lowerIds[0] = admin1.getId();
                 break;