提交 95227396 authored 作者: 吴德鹏's avatar 吴德鹏

Braintree支付

上级 e06c27d7
......@@ -5,12 +5,10 @@ import com.braintreegateway.*;
import com.example.afrishop_v3.models.TbCfOrder;
import com.example.afrishop_v3.repository.TbCfOrderRepository;
import com.example.afrishop_v3.util.GatewayFactory;
import net.sf.json.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
......@@ -25,6 +23,7 @@ import java.util.Optional;
* @Description:Braintree支付
*/
@RestController
@RequestMapping("/braintree")
public class BraintreeController {
private static BraintreeGateway gateway = GatewayFactory.getlisiGateway();
......@@ -70,6 +69,9 @@ public class BraintreeController {
.done();
Result<Transaction> result = gateway.transaction().sale(request);
System.err.println(JSONObject.fromObject(result));
System.out.println("=============================================");
System.out.println("支付状态:" + result.isSuccess());
if (result.isSuccess()) {
resp.sendRedirect(PAYPAL_SUCCESS_PAGE);
......
......@@ -81,7 +81,7 @@ public class FlutterWaveController extends Controller {
public ResponseEntity<String> payForOrderByCard(@RequestParam("orderId") String orderId, @RequestBody FlutterWaveCard flutterWaveCard) {
RaveConstant.PUBLIC_KEY = PUBLIC_KEY;
RaveConstant.SECRET_KEY = SECRET_KEY;
RaveConstant.ENVIRONMENT = Environment.LIVE; //or LIVE
RaveConstant.ENVIRONMENT = Environment.STAGING; //or STAGING
// Result result = new Result();
Optional<TbCfOrder> byId = repository.findById(orderId);
......@@ -135,7 +135,7 @@ public class FlutterWaveController extends Controller {
public ResponseEntity<String> payForOrderByPhone(@RequestParam("orderId") String orderId, @RequestBody FlutterWaveCard flutterWaveCard) {
RaveConstant.PUBLIC_KEY = PUBLIC_KEY;
RaveConstant.SECRET_KEY = SECRET_KEY;
RaveConstant.ENVIRONMENT = Environment.LIVE; //or LIVE
RaveConstant.ENVIRONMENT = Environment.STAGING; //or STAGING
// Result result = new Result();
Optional<TbCfOrder> byId = repository.findById(orderId);
......
......@@ -283,7 +283,8 @@ public class ItemController {
// }
String nick = c.getUserName();
String newNick = nick.substring(0, 1) + "***" + nick.substring(nick.length() - 1);
// String newNick = nick.substring(0, 1) + "***" + nick.substring(nick.length() - 1);
String newNick = String.format("%s***%s", nick.charAt(0), nick.charAt(nick.length() - 1));
c.setUserName(newNick);
if (!StringUtils.isBlank(userId)) {
String liked = (String) redisCache.get(key + userId + "_" + c.getId());
......
......@@ -176,6 +176,8 @@ public class OrderController extends Controller {
// order.setCoupon(coupon);
// }
// }
boolean exists = activityRepository.existsByStatus(1);
order.setHasActivity(exists);
order.setOpen(open);
order.setCouponMap(map);
order.getItemOrderListFromCartList(list, itemRepository, activityRepository);
......
......@@ -180,6 +180,9 @@ public class TbCfOrder {
@Transient
private boolean open = false;
@Transient
private boolean hasActivity;
public Map<String, Object> getCouponMap() {
return couponMap;
}
......
......@@ -30,4 +30,7 @@ public interface ActivityRepository extends JpaRepository<Activity, String> {
@Query(value = "select * from Activity a where CURRENT_TIMESTAMP between a.start_time and a.end_time and a.status=1 and a.use_type=:useType order by a.create_time desc ", nativeQuery = true)
List<Activity> findAllByUseType(Integer useType);
boolean existsByStatus(Integer status);
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论