CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-com-github-binarywang--weixin-java-miniapp

Comprehensive Java SDK for WeChat MiniApp development with complete platform integration

Pending
Overview
Eval results
Files

ecommerce.mddocs/

E-commerce

Complete e-commerce platform integration including shop management, product catalogs, order processing, payments, logistics, and after-sales services for WeChat MiniApp commerce functionality.

Capabilities

Shop Management Services

Core shop registration, account management, and configuration services for mini program e-commerce.

public interface WxMaShopRegisterService {
    // Shop registration and setup
}

public interface WxMaShopAccountService {
    // Shop account information management
    WxMaShopAccountGetInfo getAccountInfo() throws WxErrorException;
}

public interface WxMaShopAuditService {
    // Shop and product audit management
}

Product Management Services

Comprehensive product catalog management including SPU/SKU, categories, and images.

public interface WxMaShopSpuService {
    // Product Management
    String addSpu(WxMaShopSpuInfo spuInfo) throws WxErrorException;
    boolean delSpu(String productId) throws WxErrorException;
    boolean updateSpu(WxMaShopSpuInfo spuInfo) throws WxErrorException; 
    WxMaShopSpuInfo getSpu(String productId) throws WxErrorException;
    WxMaShopSpuListResult getSpuList(Integer status, Integer page, Integer pageSize) throws WxErrorException;
    
    // Listing Management
    boolean updateSpuListing(String productId, Integer listing) throws WxErrorException;
    WxMaShopSpuListResult getSpuList(Integer status, Integer page, Integer pageSize) throws WxErrorException;
    
    // Batch Operations
    boolean batchUpdateSpuListing(List<String> productIds, Integer listing) throws WxErrorException;
    
    // Stock Management
    boolean updateStock(String productId, String skuId, Integer stockNum) throws WxErrorException;
    WxMaShopStockResult getStock(String productId, String skuId) throws WxErrorException;
}

public interface WxMaShopCatService {
    // Product category management
    List<WxMaShopCatInfo> getCatList() throws WxErrorException;
}

public interface WxMaShopImgService {
    // Image upload and management
    WxMaShopImgUploadResult uploadImg(File imgFile) throws WxErrorException;
    WxMaShopImgUploadResult uploadImg(String imgUrl) throws WxErrorException;
}

Order Management Services

Complete order lifecycle management from creation to fulfillment.

public interface WxMaShopOrderService {
    // Order Query Operations
    WxMaShopOrderDetailResult getOrder(String orderId) throws WxErrorException;
    WxMaShopOrderListResult getOrderList(WxMaShopOrderListRequest request) throws WxErrorException;
    WxMaShopOrderListResult getOrderListByStatus(Integer status, Integer page, Integer pageSize) throws WxErrorException;
    
    // Order Management
    boolean changeOrderPrice(String orderId, String changeType, Long changeValue) throws WxErrorException;
    boolean closeOrder(String orderId) throws WxErrorException;
    boolean confirmOrder(String orderId) throws WxErrorException;
    boolean cancelOrder(String orderId, String cancelReason) throws WxErrorException;
    
    // Order Processing
    boolean deliverOrder(String orderId, WxMaShopDeliveryInfo deliveryInfo) throws WxErrorException;
    boolean confirmReceive(String orderId) throws WxErrorException;
    
    // Certificates and Documentation
    boolean uploadCertificates(String orderId, List<WxMaShopOrderCertificate> certificates) throws WxErrorException;
    List<WxMaShopOrderCertificate> getCertificates(String orderId) throws WxErrorException;
    
    // Order Statistics
    WxMaShopOrderStatsResult getOrderStats(Date startDate, Date endDate) throws WxErrorException;
}

public interface WxMaShopAfterSaleService {
    // After-sales and refund management
    WxMaShopAfterSaleOrderResult getAfterSaleOrder(String afterSaleOrderId) throws WxErrorException;
    boolean acceptAfterSale(String afterSaleOrderId, String addressId) throws WxErrorException;
    boolean rejectAfterSale(String afterSaleOrderId, String rejectReason) throws WxErrorException;
    boolean uploadReturnInfo(String afterSaleOrderId, WxMaShopReturnInfo returnInfo) throws WxErrorException;
}

Payment Services

Payment processing and transaction management for mini program shop orders.

public interface WxMaShopPayService {
    // Payment operations
    WxMaShopPayOrderResult createPayOrder(WxMaShopPayOrderRequest request) throws WxErrorException;
    boolean notifyPayment(String orderId, String actionType, String transactionId) throws WxErrorException;
}

Logistics and Delivery

Comprehensive logistics management including shipping, tracking, and delivery services.

public interface WxMaShopDeliveryService {
    // Logistics management
    WxMaShopDeliveryListResult getDeliveryList() throws WxErrorException;
    boolean sendDelivery(String orderId, String deliveryId, String waybillId) throws WxErrorException;
    boolean recieveDelivery(String orderId) throws WxErrorException;
}

Promotions and Coupons

Marketing tools including coupons, discounts, and promotional campaigns.

public interface WxMaShopCouponService {
    // Coupon management
    String createCoupon(WxMaShopCouponInfo couponInfo) throws WxErrorException;
    boolean updateCoupon(WxMaShopCouponInfo couponInfo) throws WxErrorException;
    WxMaShopCouponInfo getCoupon(String couponId) throws WxErrorException;
    WxMaShopCouponListResult getCouponList(Integer status, Integer page, Integer pageSize) throws WxErrorException;
    boolean updateCouponStatus(String couponId, Integer status) throws WxErrorException;
}

Affiliate and Sharing

Affiliate marketing and sharer management for social commerce.

public interface WxMaShopSharerService {
    // Affiliate/sharer management
    boolean bindSharer(String openid, String sharerType) throws WxErrorException;
    WxMaShopSharerInfo getSharer(String openid) throws WxErrorException;
    WxMaShopSharerListResult getSharerList(Integer page, Integer pageSize) throws WxErrorException;
    boolean unbindSharer(String openid) throws WxErrorException;
}

Product Data Models

Comprehensive data models for product management and catalog operations.

public class WxMaShopSpuInfo implements Serializable {
    private String productId;               // Product ID
    private String title;                   // Product title
    private String subTitle;               // Subtitle
    private String mainImgUrl;             // Main image URL
    private List<String> imgUrls;          // Image URLs
    private String detail;                 // Product description
    private Integer brandId;               // Brand ID
    private List<Integer> catIds;          // Category IDs
    private List<WxMaShopSkuInfo> skus;    // SKU information
    private Map<String, Object> attrs;     // Product attributes
    private Integer status;                // Status (0: not listed, 1: listed)
    private Integer listing;               // Listing status
    private Long createTime;               // Creation timestamp
    private Long updateTime;               // Update timestamp
    
    // Getters and setters
    public String getProductId();
    public void setProductId(String productId);
    public String getTitle();
    public void setTitle(String title);
    public String getSubTitle();
    public void setSubTitle(String subTitle);
    public String getMainImgUrl();
    public void setMainImgUrl(String mainImgUrl);
    public List<String> getImgUrls();
    public void setImgUrls(List<String> imgUrls);
    public List<WxMaShopSkuInfo> getSkus();
    public void setSkus(List<WxMaShopSkuInfo> skus);
    
    // Utility methods
    public static WxMaShopSpuInfo fromJson(String json);
    public String toJson();
}

public class WxMaShopSkuInfo implements Serializable {
    private String skuId;                   // SKU ID
    private String outSkuId;               // External SKU ID
    private String thumbImg;               // Thumbnail image
    private Integer salePrice;             // Sale price (in cents)
    private Integer marketPrice;           // Market price (in cents)
    private Integer stockNum;              // Stock quantity
    private String barcode;                // Barcode
    private String skuCode;                // SKU code
    private List<WxMaShopSkuAttr> skuAttrs; // SKU attributes
    
    // Getters and setters
    public String getSkuId();
    public void setSkuId(String skuId);
    public Integer getSalePrice();
    public void setSalePrice(Integer salePrice);
    public Integer getStockNum();
    public void setStockNum(Integer stockNum);
    public List<WxMaShopSkuAttr> getSkuAttrs();
    public void setSkuAttrs(List<WxMaShopSkuAttr> skuAttrs);
}

public class WxMaShopSkuAttr {
    private String attrKey;                // Attribute key
    private String attrValue;              // Attribute value
    
    public String getAttrKey();
    public void setAttrKey(String attrKey);
    public String getAttrValue();
    public void setAttrValue(String attrValue);
}

Order Data Models

Data models for order management and processing.

public class WxMaShopOrderInfo implements Serializable {
    private String orderId;                 // Order ID
    private String openid;                  // User OpenID
    private Integer orderStatus;            // Order status
    private Integer paymentMethod;          // Payment method
    private Integer totalPrice;             // Total price (in cents)
    private Integer freight;                // Freight cost
    private WxMaShopAddressInfo addressInfo; // Delivery address
    private List<WxMaShopOrderItem> orderItems; // Order items
    private Long createTime;                // Creation time
    private Long payTime;                   // Payment time
    
    // Getters and setters
    public String getOrderId();
    public void setOrderId(String orderId);
    public String getOpenid();
    public void setOpenid(String openid);
    public Integer getOrderStatus();
    public void setOrderStatus(Integer orderStatus);
    public Integer getTotalPrice();
    public void setTotalPrice(Integer totalPrice);
    public List<WxMaShopOrderItem> getOrderItems();
    public void setOrderItems(List<WxMaShopOrderItem> orderItems);
}

public class WxMaShopOrderItem implements Serializable {
    private String productId;               // Product ID
    private String skuId;                   // SKU ID
    private String productTitle;            // Product title
    private String skuTitle;               // SKU title
    private Integer price;                  // Unit price
    private Integer quantity;               // Quantity
    private String imgUrl;                  // Product image
    
    // Getters and setters
    public String getProductId();
    public void setProductId(String productId);
    public String getSkuId();
    public void setSkuId(String skuId);
    public Integer getPrice();
    public void setPrice(Integer price);
    public Integer getQuantity();
    public void setQuantity(Integer quantity);
}

Usage Examples

Product Management

Add New Product (SPU)

@Service
public class ProductService {
    
    @Autowired
    private WxMaService wxMaService;
    
    public String addProduct(ProductCreateRequest request) {
        try {
            // Upload product images
            List<String> imageUrls = new ArrayList<>();
            for (File imageFile : request.getImageFiles()) {
                WxMaShopImgUploadResult result = wxMaService.getShopImgService()
                    .uploadImg(imageFile);
                imageUrls.add(result.getImgUrl());
            }
            
            // Create SPU
            WxMaShopSpuInfo spuInfo = new WxMaShopSpuInfo();
            spuInfo.setTitle(request.getTitle());
            spuInfo.setSubTitle(request.getSubTitle());
            spuInfo.setMainImgUrl(imageUrls.get(0));
            spuInfo.setImgUrls(imageUrls);
            spuInfo.setDetail(request.getDescription());
            spuInfo.setBrandId(request.getBrandId());
            spuInfo.setCatIds(request.getCategoryIds());
            
            // Add SKUs
            List<WxMaShopSkuInfo> skus = new ArrayList<>();
            for (SkuCreateRequest skuRequest : request.getSkus()) {
                WxMaShopSkuInfo sku = new WxMaShopSkuInfo();
                sku.setOutSkuId(skuRequest.getExternalSkuId());
                sku.setSalePrice(skuRequest.getSalePrice());
                sku.setMarketPrice(skuRequest.getMarketPrice());
                sku.setStockNum(skuRequest.getStockQuantity());
                sku.setBarcode(skuRequest.getBarcode());
                
                // Set SKU attributes (size, color, etc.)
                List<WxMaShopSkuAttr> attrs = new ArrayList<>();
                for (Map.Entry<String, String> attr : skuRequest.getAttributes().entrySet()) {
                    WxMaShopSkuAttr skuAttr = new WxMaShopSkuAttr();
                    skuAttr.setAttrKey(attr.getKey());
                    skuAttr.setAttrValue(attr.getValue());
                    attrs.add(skuAttr);
                }
                sku.setSkuAttrs(attrs);
                
                skus.add(sku);
            }
            spuInfo.setSkus(skus);
            
            // Add product to WeChat Shop
            String productId = wxMaService.getShopSpuService().addSpu(spuInfo);
            
            logger.info("Product added successfully: {}", productId);
            return productId;
            
        } catch (WxErrorException e) {
            logger.error("Failed to add product: {}", e.getMessage());
            throw new ProductCreationException("Failed to create product", e);
        }
    }
}

Update Product Information

public void updateProduct(String productId, ProductUpdateRequest request) {
    try {
        // Get existing product
        WxMaShopSpuInfo existingProduct = wxMaService.getShopSpuService()
            .getSpu(productId);
        
        // Update fields
        if (request.getTitle() != null) {
            existingProduct.setTitle(request.getTitle());
        }
        
        if (request.getSubTitle() != null) {
            existingProduct.setSubTitle(request.getSubTitle());
        }
        
        if (request.getDescription() != null) {
            existingProduct.setDetail(request.getDescription());
        }
        
        // Update images if provided
        if (request.getNewImageFiles() != null && !request.getNewImageFiles().isEmpty()) {
            List<String> newImageUrls = new ArrayList<>();
            for (File imageFile : request.getNewImageFiles()) {
                WxMaShopImgUploadResult result = wxMaService.getShopImgService()
                    .uploadImg(imageFile);
                newImageUrls.add(result.getImgUrl());
            }
            existingProduct.setImgUrls(newImageUrls);
            existingProduct.setMainImgUrl(newImageUrls.get(0));
        }
        
        // Update SKUs
        if (request.getSkuUpdates() != null) {
            List<WxMaShopSkuInfo> updatedSkus = new ArrayList<>();
            for (WxMaShopSkuInfo existingSku : existingProduct.getSkus()) {
                SkuUpdateRequest skuUpdate = request.getSkuUpdates().get(existingSku.getSkuId());
                if (skuUpdate != null) {
                    if (skuUpdate.getSalePrice() != null) {
                        existingSku.setSalePrice(skuUpdate.getSalePrice());
                    }
                    if (skuUpdate.getStockQuantity() != null) {
                        existingSku.setStockNum(skuUpdate.getStockQuantity());
                    }
                }
                updatedSkus.add(existingSku);
            }
            existingProduct.setSkus(updatedSkus);
        }
        
        // Update in WeChat
        boolean success = wxMaService.getShopSpuService().updateSpu(existingProduct);
        
        if (success) {
            logger.info("Product updated successfully: {}", productId);
        }
        
    } catch (WxErrorException e) {
        logger.error("Failed to update product {}: {}", productId, e.getMessage());
        throw new ProductUpdateException("Failed to update product", e);
    }
}

Product Listing Management

public void updateProductListing(String productId, boolean listed) {
    try {
        int listingStatus = listed ? 1 : 0;
        
        boolean success = wxMaService.getShopSpuService()
            .updateSpuListing(productId, listingStatus);
        
        if (success) {
            logger.info("Product {} listing status updated to: {}", 
                       productId, listed ? "listed" : "unlisted");
        }
        
    } catch (WxErrorException e) {
        logger.error("Failed to update listing for product {}: {}", 
                   productId, e.getMessage());
    }
}

public List<WxMaShopSpuInfo> getActiveProducts(int page, int pageSize) {
    try {
        WxMaShopSpuListResult result = wxMaService.getShopSpuService()
            .getSpuList(1, page, pageSize); // Status 1 = listed
        
        return result.getSpus();
        
    } catch (WxErrorException e) {
        logger.error("Failed to get active products: {}", e.getMessage());
        return Collections.emptyList();
    }
}

Order Management

Order Processing Workflow

@Service
public class OrderProcessingService {
    
    public void processOrder(String orderId) {
        try {
            // Get order details
            WxMaShopOrderDetailResult orderResult = wxMaService.getShopOrderService()
                .getOrder(orderId);
            
            WxMaShopOrderInfo order = orderResult.getOrder();
            
            switch (order.getOrderStatus()) {
                case 1: // Pending payment
                    handlePendingPayment(order);
                    break;
                case 2: // Paid, pending fulfillment
                    handlePaidOrder(order);
                    break;
                case 3: // Shipped
                    handleShippedOrder(order);
                    break;
                case 4: // Completed
                    handleCompletedOrder(order);
                    break;
                case 5: // Cancelled
                    handleCancelledOrder(order);
                    break;
            }
            
        } catch (WxErrorException e) {
            logger.error("Failed to process order {}: {}", orderId, e.getMessage());
        }
    }
    
    private void handlePaidOrder(WxMaShopOrderInfo order) {
        try {
            // Check inventory
            boolean inventoryAvailable = checkInventory(order.getOrderItems());
            
            if (!inventoryAvailable) {
                // Close order due to insufficient inventory
                wxMaService.getShopOrderService().closeOrder(order.getOrderId());
                notificationService.notifyInventoryShortage(order);
                return;
            }
            
            // Reserve inventory
            inventoryService.reserveInventory(order.getOrderItems());
            
            // Create fulfillment record
            fulfillmentService.createFulfillment(order);
            
            logger.info("Order {} processed for fulfillment", order.getOrderId());
            
        } catch (Exception e) {
            logger.error("Failed to handle paid order {}: {}", 
                       order.getOrderId(), e.getMessage());
        }
    }
}

Order Query and Management

@RestController
@RequestMapping("/api/orders")
public class OrderController {
    
    @GetMapping
    public ResponseEntity<PageResult<WxMaShopOrderInfo>> getOrders(
            @RequestParam(defaultValue = "0") int page,
            @RequestParam(defaultValue = "20") int pageSize,
            @RequestParam(required = false) Integer status,
            @RequestParam(required = false) String startTime,
            @RequestParam(required = false) String endTime) {
        
        try {
            WxMaShopOrderListRequest request = new WxMaShopOrderListRequest();
            request.setPage(page);
            request.setPageSize(pageSize);
            request.setStatus(status);
            request.setStartTime(startTime);
            request.setEndTime(endTime);
            
            WxMaShopOrderListResult result = wxMaService.getShopOrderService()
                .getOrderList(request);
            
            PageResult<WxMaShopOrderInfo> pageResult = new PageResult<>();
            pageResult.setItems(result.getOrderList());
            pageResult.setTotalCount(result.getTotalNum());
            pageResult.setPage(page);
            pageResult.setPageSize(pageSize);
            
            return ResponseEntity.ok(pageResult);
            
        } catch (WxErrorException e) {
            logger.error("Failed to get orders: {}", e.getMessage());
            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
        }
    }
    
    @PostMapping("/{orderId}/price")
    public ResponseEntity<Void> changeOrderPrice(
            @PathVariable String orderId,
            @RequestBody PriceChangeRequest request) {
        
        try {
            boolean success = wxMaService.getShopOrderService().changeOrderPrice(
                orderId,
                request.getChangeType(),    // "increase" or "decrease"
                request.getChangeValue()    // Amount in cents
            );
            
            if (success) {
                return ResponseEntity.ok().build();
            } else {
                return ResponseEntity.badRequest().build();
            }
            
        } catch (WxErrorException e) {
            logger.error("Failed to change order price: {}", e.getMessage());
            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
        }
    }
}

Payment Integration

Payment Order Creation

@Service
public class PaymentService {
    
    public WxMaShopPayOrderResult createPaymentOrder(PaymentOrderRequest request) {
        try {
            WxMaShopPayOrderRequest payOrderRequest = new WxMaShopPayOrderRequest();
            payOrderRequest.setOrderId(request.getOrderId());
            payOrderRequest.setOpenid(request.getOpenid());
            payOrderRequest.setOutTradeNo(request.getOutTradeNo());
            payOrderRequest.setTotalFee(request.getTotalFee());
            payOrderRequest.setBody(request.getDescription());
            payOrderRequest.setNotifyUrl(request.getNotifyUrl());
            
            WxMaShopPayOrderResult result = wxMaService.getShopPayService()
                .createPayOrder(payOrderRequest);
            
            logger.info("Payment order created: {}", result.getPaymentParams());
            return result;
            
        } catch (WxErrorException e) {
            logger.error("Failed to create payment order: {}", e.getMessage());
            throw new PaymentException("Payment order creation failed", e);
        }
    }
    
    @PostMapping("/payment/notify")
    public ResponseEntity<String> handlePaymentNotification(
            @RequestBody String notificationData,
            HttpServletRequest request) {
        
        try {
            // Verify signature
            String signature = request.getHeader("Wechatpay-Signature");
            boolean signatureValid = verifySignature(notificationData, signature);
            
            if (!signatureValid) {
                return ResponseEntity.status(HttpStatus.UNAUTHORIZED)
                    .body("Invalid signature");
            }
            
            // Parse notification
            PaymentNotification notification = parseNotification(notificationData);
            
            // Notify WeChat of payment
            wxMaService.getShopPayService().notifyPayment(
                notification.getOrderId(),
                "pay_success",
                notification.getTransactionId()
            );
            
            // Process the paid order
            orderProcessingService.processPaymentSuccess(notification);
            
            return ResponseEntity.ok("SUCCESS");
            
        } catch (Exception e) {
            logger.error("Payment notification handling failed: {}", e.getMessage());
            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
                .body("Processing failed");
        }
    }
}

Logistics Management

Shipping and Delivery

@Service
public class LogisticsService {
    
    public void shipOrder(String orderId, String deliveryCompanyId, String waybillId) {
        try {
            // Send delivery information
            boolean success = wxMaService.getShopDeliveryService()
                .sendDelivery(orderId, deliveryCompanyId, waybillId);
            
            if (success) {
                logger.info("Order {} shipped with waybill: {}", orderId, waybillId);
                
                // Send shipping notification to user
                notificationService.sendShippingNotification(orderId, waybillId);
            }
            
        } catch (WxErrorException e) {
            logger.error("Failed to ship order {}: {}", orderId, e.getMessage());
        }
    }
    
    public void confirmDelivery(String orderId) {
        try {
            boolean success = wxMaService.getShopDeliveryService()
                .recieveDelivery(orderId);
            
            if (success) {
                logger.info("Delivery confirmed for order: {}", orderId);
                
                // Process order completion
                orderService.completeOrder(orderId);
            }
            
        } catch (WxErrorException e) {
            logger.error("Failed to confirm delivery for order {}: {}", 
                       orderId, e.getMessage());
        }
    }
    
    public List<DeliveryCompany> getAvailableDeliveryCompanies() {
        try {
            WxMaShopDeliveryListResult result = wxMaService.getShopDeliveryService()
                .getDeliveryList();
            
            return result.getDeliveryList().stream()
                .map(this::convertToDeliveryCompany)
                .collect(Collectors.toList());
                
        } catch (WxErrorException e) {
            logger.error("Failed to get delivery companies: {}", e.getMessage());
            return Collections.emptyList();
        }
    }
}

After-Sales Management

@Service
public class AfterSalesService {
    
    public void processAfterSaleRequest(String afterSaleOrderId) {
        try {
            WxMaShopAfterSaleOrderResult result = wxMaService.getShopAfterSaleService()
                .getAfterSaleOrder(afterSaleOrderId);
            
            WxMaShopAfterSaleOrder afterSaleOrder = result.getAfterSaleOrder();
            
            // Auto-approve for certain conditions
            if (shouldAutoApprove(afterSaleOrder)) {
                approveAfterSale(afterSaleOrderId);
            } else {
                // Manual review required
                afterSaleReviewService.queueForReview(afterSaleOrder);
            }
            
        } catch (WxErrorException e) {
            logger.error("Failed to process after-sale request {}: {}", 
                       afterSaleOrderId, e.getMessage());
        }
    }
    
    public void approveAfterSale(String afterSaleOrderId) {
        try {
            // Accept the after-sale request
            boolean success = wxMaService.getShopAfterSaleService()
                .acceptAfterSale(afterSaleOrderId, "default_address_id");
            
            if (success) {
                logger.info("After-sale request approved: {}", afterSaleOrderId);
                
                // Send approval notification to customer
                notificationService.sendAfterSaleApprovalNotification(afterSaleOrderId);
            }
            
        } catch (WxErrorException e) {
            logger.error("Failed to approve after-sale {}: {}", 
                       afterSaleOrderId, e.getMessage());
        }
    }
    
    public void rejectAfterSale(String afterSaleOrderId, String reason) {
        try {
            boolean success = wxMaService.getShopAfterSaleService()
                .rejectAfterSale(afterSaleOrderId, reason);
            
            if (success) {
                logger.info("After-sale request rejected: {} - Reason: {}", 
                           afterSaleOrderId, reason);
            }
            
        } catch (WxErrorException e) {
            logger.error("Failed to reject after-sale {}: {}", 
                       afterSaleOrderId, e.getMessage());
        }
    }
}

Coupon Management

@Service
public class CouponService {
    
    public String createDiscountCoupon(CouponCreateRequest request) {
        try {
            WxMaShopCouponInfo couponInfo = new WxMaShopCouponInfo();
            couponInfo.setName(request.getName());
            couponInfo.setType(request.getType());           // 1: discount, 2: cash
            couponInfo.setDiscountCondition(request.getMinAmount());
            couponInfo.setDiscountFee(request.getDiscountAmount());
            couponInfo.setStartTime(request.getStartTime());
            couponInfo.setEndTime(request.getEndTime());
            couponInfo.setStockNum(request.getQuantity());
            couponInfo.setReceiveNum(0);
            
            String couponId = wxMaService.getShopCouponService()
                .createCoupon(couponInfo);
            
            logger.info("Coupon created: {} - {}", couponId, request.getName());
            return couponId;
            
        } catch (WxErrorException e) {
            logger.error("Failed to create coupon: {}", e.getMessage());
            throw new CouponCreationException("Coupon creation failed", e);
        }
    }
    
    public void activateCoupon(String couponId) {
        try {
            boolean success = wxMaService.getShopCouponService()
                .updateCouponStatus(couponId, 1); // 1 = active
            
            if (success) {
                logger.info("Coupon activated: {}", couponId);
            }
            
        } catch (WxErrorException e) {
            logger.error("Failed to activate coupon {}: {}", couponId, e.getMessage());
        }
    }
}

This e-commerce module provides comprehensive functionality for building and managing a complete WeChat MiniApp shop with product catalogs, order processing, payment integration, logistics management, and customer service features.

Install with Tessl CLI

npx tessl i tessl/maven-com-github-binarywang--weixin-java-miniapp

docs

analytics.md

cloud-development.md

configuration.md

core-services.md

development-tools.md

ecommerce.md

index.md

live-streaming.md

logistics.md

media-content.md

messaging.md

qr-codes.md

user-management.md

tile.json