|
@@ -15,6 +15,7 @@ import com.izouma.nineth.repo.GiftOrderRepo;
|
|
|
import com.izouma.nineth.repo.MintOrderRepo;
|
|
import com.izouma.nineth.repo.MintOrderRepo;
|
|
|
import com.izouma.nineth.repo.OrderRepo;
|
|
import com.izouma.nineth.repo.OrderRepo;
|
|
|
import com.izouma.nineth.utils.DateTimeUtils;
|
|
import com.izouma.nineth.utils.DateTimeUtils;
|
|
|
|
|
+import com.izouma.nineth.utils.MD5Util;
|
|
|
import com.izouma.nineth.utils.SnowflakeIdWorker;
|
|
import com.izouma.nineth.utils.SnowflakeIdWorker;
|
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -25,14 +26,13 @@ import org.springframework.stereotype.Service;
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.net.URLDecoder;
|
|
import java.net.URLDecoder;
|
|
|
|
|
+import java.net.URLEncoder;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.text.DecimalFormat;
|
|
import java.text.DecimalFormat;
|
|
|
import java.text.DecimalFormatSymbols;
|
|
import java.text.DecimalFormatSymbols;
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.HashMap;
|
|
|
|
|
-import java.util.Locale;
|
|
|
|
|
-import java.util.Map;
|
|
|
|
|
-import java.util.Optional;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
|
|
@Service
|
|
@Service
|
|
|
@AllArgsConstructor
|
|
@AllArgsConstructor
|
|
@@ -346,6 +346,98 @@ public class SandPayService {
|
|
|
return res.getJSONObject("body").getString("credential");
|
|
return res.getJSONObject("body").getString("credential");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public String payQuickBind(String orderId, String subject, BigDecimal amount, LocalDateTime expireAt,
|
|
|
|
|
+ String type, String returnUrl, Long userId, String name, String idNo) {
|
|
|
|
|
+ String pOrderId = paddingOrderId(orderId);
|
|
|
|
|
+
|
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
|
|
+ String createTime = sdf.format(calendar.getTime());
|
|
|
|
|
+ calendar.add(Calendar.HOUR, 1);
|
|
|
|
|
+ String endTime = sdf.format(calendar.getTime());
|
|
|
|
|
+
|
|
|
|
|
+ String version = "10";
|
|
|
|
|
+ String mer_no = sandPayProperties.getMid();
|
|
|
|
|
+ //key1
|
|
|
|
|
+ String mer_key = "S+ICbmNah6PrBJ5Negl3adhc1Z1YIWy2g4NYKglZlOdlqRNcSK4EtNoff1X0g1+YcKvdbn60nDQ=";
|
|
|
|
|
+ UUID uuid = UUID.randomUUID();
|
|
|
|
|
+ String mer_order_no = uuid.toString().replaceAll("-", "");
|
|
|
|
|
+ String notify_url = sandPayProperties.getNotifyUrl();
|
|
|
|
|
+ String order_amt = amount.toPlainString();
|
|
|
|
|
+ //"userId":"用户在商户下唯一标识 1-10位","userName":"证件姓名","idCard":"18位身份证号码"
|
|
|
|
|
+ String pay_extra = "{\"userId\":\"" + userId + "\",\"userName\":\"" + name + "\",\"idCard\":\"" + idNo + "\"}";
|
|
|
|
|
+ //md5key
|
|
|
|
|
+ String key = "hqjaLGvxlOl6FvUmVkwPvGRUz87WPlXFxd8gCVbmg/NjQYBijBiPoEL0Tiz+vcoIfVv0rryZ6BNhA1fB2EXVHUlY+10niZ7pS8uq8g0wXKHvgpKNIKgJmztiHrBkFR1ZJTpJBY1UEpVixuz+UKFTiw==";
|
|
|
|
|
+
|
|
|
|
|
+ JSONObject extend = new JSONObject();
|
|
|
|
|
+ extend.put("type", type);
|
|
|
|
|
+ extend.put("orderId", pOrderId);
|
|
|
|
|
+ extend.put("id", pOrderId);
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, String> map = new LinkedHashMap<>();
|
|
|
|
|
+ map.put("accsplit_flag", "NO");
|
|
|
|
|
+ map.put("create_ip", "127_0_0_1");
|
|
|
|
|
+ map.put("create_time", createTime);
|
|
|
|
|
+ map.put("extend", extend.toJSONString());
|
|
|
|
|
+// if(!(gh_static_url==null||"".equals(gh_static_url)))map.put("gh_static_url",gh_static_url);;
|
|
|
|
|
+ map.put("mer_key", mer_key);
|
|
|
|
|
+ map.put("mer_no", mer_no);
|
|
|
|
|
+ map.put("mer_order_no", mer_order_no);
|
|
|
|
|
+ map.put("notify_url", notify_url);
|
|
|
|
|
+ map.put("order_amt", order_amt);
|
|
|
|
|
+ map.put("pay_extra", pay_extra);
|
|
|
|
|
+ map.put("return_url", returnUrl);
|
|
|
|
|
+ map.put("sign_type", "MD5");
|
|
|
|
|
+ map.put("store_id", "000000");
|
|
|
|
|
+ map.put("version", version);
|
|
|
|
|
+ map.put("key", key);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+// map.put("extend", "aaa");
|
|
|
|
|
+// map.put("expire_time",endTime);
|
|
|
|
|
+// map.put("goods_name",goods_name);
|
|
|
|
|
+// map.put("product_code","02010006");
|
|
|
|
|
+// map.put("clear_cycle","0");
|
|
|
|
|
+
|
|
|
|
|
+ String signature = "";
|
|
|
|
|
+
|
|
|
|
|
+ for (String s : map.keySet()) {
|
|
|
|
|
+ if (!(map.get(s) == null || map.get(s).equals(""))) {
|
|
|
|
|
+ signature += s + "=";
|
|
|
|
|
+ signature += map.get(s) + "&";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ signature = signature.substring(0, signature.length() - 1);
|
|
|
|
|
+ String sign = MD5Util.encode(signature).toUpperCase();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //url
|
|
|
|
|
+ return "https://sandcash.mixienet.com.cn/pay/h5/quicktopup?" +
|
|
|
|
|
+ "version=" + version +
|
|
|
|
|
+ "&mer_no=" + mer_no +
|
|
|
|
|
+ "&mer_key=" + URLEncoder.encode(mer_key, StandardCharsets.UTF_8) +
|
|
|
|
|
+ "&mer_order_no=" + mer_order_no +
|
|
|
|
|
+ "&create_time=" + createTime +
|
|
|
|
|
+ "&expire_time=" + getTimeout(expireAt, 0) +
|
|
|
|
|
+ "&extend=" + URLEncoder.encode(extend.toJSONString(), StandardCharsets.UTF_8) +
|
|
|
|
|
+ "&order_amt=" + order_amt +
|
|
|
|
|
+ "¬ify_url=" + URLEncoder.encode(notify_url, StandardCharsets.UTF_8) +
|
|
|
|
|
+ "&return_url=" + URLEncoder.encode(returnUrl, StandardCharsets.UTF_8) +
|
|
|
|
|
+ "&create_ip=127_0_0_1" +
|
|
|
|
|
+ "&goods_name=" + URLEncoder.encode(subject, StandardCharsets.UTF_8) +
|
|
|
|
|
+ "&store_id=000000" +
|
|
|
|
|
+ "&product_code=06030003" +
|
|
|
|
|
+ "&clear_cycle=3" +
|
|
|
|
|
+ "&pay_extra=" + URLEncoder.encode(pay_extra, StandardCharsets.UTF_8) +
|
|
|
|
|
+ "&meta_option=%5B%7B%22s%22%3A%22Android%22,%22n%22%3A%22wxDemo%22,%22id%22%3A%22com.pay.paytypetest%22,%22sc%22%3A%22com.pay.paytypetest%22%7D%5D" +
|
|
|
|
|
+ "&accsplit_flag=NO" +
|
|
|
|
|
+ "&jump_scheme=" +
|
|
|
|
|
+// "&gh_static_url="+gh_static_url+""+
|
|
|
|
|
+ "&sign_type=MD5" +
|
|
|
|
|
+ "&key=" + URLEncoder.encode(key, StandardCharsets.UTF_8) +
|
|
|
|
|
+ "&sign=" + sign;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Cacheable(value = "sandPayQuick", key = "#orderId")
|
|
@Cacheable(value = "sandPayQuick", key = "#orderId")
|
|
|
public String payMintQuick(Long orderId) {
|
|
public String payMintQuick(Long orderId) {
|
|
|
MintOrder order = mintOrderRepo.findById(orderId).orElseThrow(new BusinessException("订单不存在"));
|
|
MintOrder order = mintOrderRepo.findById(orderId).orElseThrow(new BusinessException("订单不存在"));
|