| | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.concurrent.atomic.AtomicBoolean; |
| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import com.panzhihua.applets.config.MinioUtil; |
| | | import com.panzhihua.applets.umf.UmfPayUtil; |
| | | import com.panzhihua.applets.unionpay.Query; |
| | | import com.panzhihua.applets.unionpay.Refund; |
| | | import com.panzhihua.applets.unionpay.RefundQuery; |
| | | import com.panzhihua.applets.unionpay.UnifiedOrder; |
| | | import com.panzhihua.applets.unionpay.*; |
| | | import com.panzhihua.common.controller.BaseController; |
| | | import com.panzhihua.common.model.vos.community.Base64File; |
| | | import com.panzhihua.common.utlis.*; |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import static com.panzhihua.common.utlis.FileTypeUploadUtils.assertAllowed; |
| | | import static com.panzhihua.common.utlis.PayUtil.makeUUID; |
| | | |
| | | /** |
| | | * @program: springcloud_k8s_panzhihuazhihuishequ |
| | |
| | | public R uuUnionpayPay(@RequestParam("amount")String amount, |
| | | @RequestParam("productId")String productId, |
| | | @RequestParam("openId")String openId){ |
| | | String map= UnifiedOrder.sendOrder(amount,"uu洗车下单",productId,openId); |
| | | |
| | | LocalDateTime time=DateUtils.getCurrentDate(); |
| | | String merOrderId= UnionpayContent.TOP4+time.format(DateUtils.format_ymdhms_yyyyMMddmmHHssSSS)+makeUUID(7); |
| | | String map= UnifiedOrder.sendOrder(amount,"uu洗车下单",productId,openId,time,merOrderId); |
| | | communityService.add(productId,merOrderId,amount); |
| | | return R.ok(map); |
| | | } |
| | | |
| | |
| | | public R wsUnionpayPay(@RequestParam("amount")String amount, |
| | | @RequestParam("productId")String productId, |
| | | @RequestParam("openId")String openId){ |
| | | String map= UnifiedOrder.sendOrder(amount,"无水洗车下单",productId,openId); |
| | | LocalDateTime time=DateUtils.getCurrentDate(); |
| | | String merOrderId= UnionpayContent.TOP4+time.format(DateUtils.format_ymdhms_yyyyMMddmmHHssSSS)+makeUUID(7); |
| | | String map= UnifiedOrder.sendOrder(amount,"无水洗车下单",productId,openId,time,merOrderId); |
| | | communityService.add(productId,merOrderId,amount); |
| | | return R.ok(map); |
| | | } |
| | | |
| | |
| | | log.error("花城洗车请求参数queryEntiy :" + queryEntiy.toString()); |
| | | if(queryEntiy.getErrCode().equals("SUCCESS")) |
| | | { |
| | | //查询银联单号对应的洗车单号 |
| | | R r=communityService.carWashById(merOrderId); |
| | | if(r.getCode()==200) |
| | | { |
| | | UnionpayCarWash unionpayCarWash=(UnionpayCarWash)r.getData(); |
| | | //调用uu洗车支付成功回调 |
| | | // Map map=new HashMap(); |
| | | // map.put("orderId",respMap.get("order_id")); |
| | | // HttpClientUtil.sendPostByJson("https://uu-api.imashuo.com/notify/wx/pzh-pay",JSONObject.toJSONString(map), |
| | | // 1,"appid","10000"); |
| | | log.error("花城洗车回调成功 :" + queryEntiy.getMerOrderId()); |
| | | Map map=new HashMap(); |
| | | map.put("orderId",unionpayCarWash.getCarWashId()); |
| | | HttpClientUtil.sendPostByJson("https://uu-api.imashuo.com/notify/wx/pzh-pay",JSONObject.toJSONString(map), |
| | | 1,"appid","10000"); |
| | | log.error("花城洗车回调成功 :" + queryEntiy.getMerOrderId()+" : 洗车号" |
| | | +unionpayCarWash.getUnionpayOrderId()+" : 银联号"+unionpayCarWash.getUnionpayOrderId()); |
| | | } |
| | | |
| | | } |
| | | //调用SDK生成返回联动平台字符串,加到CONTENT中 |
| | | response.setContentType("text/html;charset=utf-8"); |
| | |
| | | if(desMap.get("orderId")!=null) |
| | | { |
| | | R r=communityService.queryById(desMap.get("orderId")); |
| | | if(r.getCode()==200) |
| | | { |
| | | UnionpayCarWash wash=(UnionpayCarWash)r.getData(); |
| | | if(wash!=null) |
| | | { |
| | | String re=Refund.sendOrder(wash.getMoney(),wash.getUnionpayOrderId()); |
| | | map.put("unionpay","退款成功"); |
| | | log.error("花城洗车银联退款成功 :" + re); |
| | | } |
| | | |
| | | } |
| | | } |
| | | return R.ok(map); |
| | |
| | | LocalDateTime time= DateUtils.getCurrentDate(); |
| | | RefundBody reqBody = new RefundBody(); |
| | | reqBody.requestTimestamp = time.format(DateUtils.format_ymdhms);// "2019-08-09 17:30:55"; |
| | | reqBody.merOrderId =UnionpayContent.TOP4+time.format(DateUtils.format_ymdhms_yyyyMMddmmHHssSSS)+makeUUID(7); |
| | | reqBody.merOrderId =refundOrderId; |
| | | reqBody.mid =UnionpayContent.MID; |
| | | reqBody.tid = UnionpayContent.TID; |
| | | reqBody.instMid = UnionpayContent.INSTMID; |
| | | reqBody.refundAmount = refundAmount; |
| | | reqBody.refundOrderId = refundOrderId; |
| | | System.out.println("request body:\n"+reqBody); |
| | | |
| | | |
| | |
| | | package com.panzhihua.applets.unionpay; |
| | | |
| | | import com.panzhihua.common.service.community.CommunityService; |
| | | import com.panzhihua.common.utlis.DateUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.codec.binary.Base64; |
| | |
| | | @Slf4j |
| | | @Component |
| | | public class UnifiedOrder { |
| | | |
| | | |
| | | // static String url = "https://test-api-open.chinaums.com/v1/netpay/wx/unified-order"; |
| | | static String url = "https://api-mop.chinaums.com/v1/netpay/wx/unified-order"; |
| | | |
| | | public static String sendOrder(String totalAmount,String orderDesc,String productId,String OpenId) |
| | | public static String sendOrder(String totalAmount,String orderDesc,String productId,String OpenId,LocalDateTime time,String merOrderId) |
| | | { |
| | | //1. 组建请求报文 |
| | | LocalDateTime time=DateUtils.getCurrentDate(); |
| | | UnifiedOrderBody reqBody = new UnifiedOrderBody(); |
| | | reqBody.requestTimestamp = time.format(DateUtils.format_ymdhms);// "2019-08-09 17:30:55"; |
| | | reqBody.merOrderId = UnionpayContent.TOP4+time.format(DateUtils.format_ymdhms_yyyyMMddmmHHssSSS)+makeUUID(7); |
| | | reqBody.merOrderId = merOrderId; |
| | | reqBody.mid = UnionpayContent.MID; |
| | | reqBody.tid = UnionpayContent.TID; |
| | | reqBody.instMid = UnionpayContent.INSTMID; |
| | |
| | | R queryById(@RequestParam("Id") String id); |
| | | |
| | | |
| | | /** |
| | | * 通过银联订单查询洗车订单 |
| | | * |
| | | * @param Id |
| | | * @return |
| | | */ |
| | | @GetMapping("/unionpay/unionpayDetail") |
| | | R carWashById(@RequestParam("Id") String id); |
| | | |
| | | /** |
| | | * 新增洗车订单和银联订单关系 |
| | | * @param carWashId |
| | | * @param unionpayOrderId |
| | | * @param money |
| | | * @return |
| | | */ |
| | | @PostMapping("/unionpay/add") |
| | | int add(@RequestParam("carWashId") String carWashId, |
| | | @RequestParam("unionpayOrderId") String unionpayOrderId, |
| | | @RequestParam("money") String money); |
| | | |
| | | |
| | | } |
| | |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.service_community.service.UnionpayCarWashService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | |
| | | return R.ok(unionpayCarWashService.queryById(id)); |
| | | } |
| | | |
| | | @GetMapping("/unionpayDetail") |
| | | public R carWashById(@RequestParam("Id") String id) |
| | | { |
| | | return R.ok(unionpayCarWashService.carWashById(id)); |
| | | } |
| | | |
| | | @PostMapping("/add") |
| | | public int inset(@RequestParam("carWashId") String carWashId, |
| | | @RequestParam("unionpayOrderId") String unionpayOrderId, |
| | | @RequestParam("money") String money) |
| | | { |
| | | return unionpayCarWashService.inset(carWashId,unionpayOrderId,money); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | public interface UnionpayCarWashDao extends BaseMapper<UnionpayCarWash> |
| | | { |
| | | UnionpayCarWash queryById(@Param("carWashId") String carWashId); |
| | | |
| | | UnionpayCarWash carWashById(@Param("unionpayId") String unionpayId); |
| | | |
| | | int inset(@Param("carWashId") String carWashId, |
| | | @Param("unionpayOrderId") String unionpayOrderId, |
| | | @Param("money") String money); |
| | | } |
| | | |
| | |
| | | public interface UnionpayCarWashService |
| | | { |
| | | UnionpayCarWash queryById(String carWashId); |
| | | |
| | | UnionpayCarWash carWashById(String unionpayId); |
| | | |
| | | int inset(String carWashId,String unionpayOrderId,String money); |
| | | } |
| | |
| | | public UnionpayCarWash queryById(String carWashId) { |
| | | return baseMapper.queryById(carWashId); |
| | | } |
| | | |
| | | @Override |
| | | public UnionpayCarWash carWashById(String unionpayId) { |
| | | return baseMapper.carWashById(unionpayId); |
| | | } |
| | | |
| | | @Override |
| | | public int inset(String carWashId, String unionpayOrderId, String money) { |
| | | return baseMapper.inset(carWashId,unionpayOrderId,money); |
| | | } |
| | | } |
| | |
| | | where car_wash_id = #{carWashId} |
| | | </select> |
| | | |
| | | <select id="carWashById" resultMap="UnionpayCarWashMap"> |
| | | select |
| | | id, |
| | | car_wash_id, |
| | | unionpay_order_id, |
| | | money |
| | | from unionpay_car_wash |
| | | where unionpay_order_id = #{unionpayId} |
| | | </select> |
| | | |
| | | <insert id="inset"> |
| | | INSERT INTO unionpay_car_wash(`car_wash_id`, `unionpay_order_id`, `money`) |
| | | VALUES (#{carWashId}, #{unionpayOrderId}, #{money}); |
| | | </insert> |
| | | |
| | | |
| | | |
| | | </mapper> |