or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

analytics.mdcloud-development.mdconfiguration.mdcore-services.mddevelopment-tools.mdecommerce.mdindex.mdlive-streaming.mdlogistics.mdmedia-content.mdmessaging.mdqr-codes.mduser-management.md

ecommerce.mddocs/

0

# E-commerce

1

2

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

3

4

## Capabilities

5

6

### Shop Management Services

7

8

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

9

10

```java { .api }

11

public interface WxMaShopRegisterService {

12

// Shop registration and setup

13

}

14

15

public interface WxMaShopAccountService {

16

// Shop account information management

17

WxMaShopAccountGetInfo getAccountInfo() throws WxErrorException;

18

}

19

20

public interface WxMaShopAuditService {

21

// Shop and product audit management

22

}

23

```

24

25

### Product Management Services

26

27

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

28

29

```java { .api }

30

public interface WxMaShopSpuService {

31

// Product Management

32

String addSpu(WxMaShopSpuInfo spuInfo) throws WxErrorException;

33

boolean delSpu(String productId) throws WxErrorException;

34

boolean updateSpu(WxMaShopSpuInfo spuInfo) throws WxErrorException;

35

WxMaShopSpuInfo getSpu(String productId) throws WxErrorException;

36

WxMaShopSpuListResult getSpuList(Integer status, Integer page, Integer pageSize) throws WxErrorException;

37

38

// Listing Management

39

boolean updateSpuListing(String productId, Integer listing) throws WxErrorException;

40

WxMaShopSpuListResult getSpuList(Integer status, Integer page, Integer pageSize) throws WxErrorException;

41

42

// Batch Operations

43

boolean batchUpdateSpuListing(List<String> productIds, Integer listing) throws WxErrorException;

44

45

// Stock Management

46

boolean updateStock(String productId, String skuId, Integer stockNum) throws WxErrorException;

47

WxMaShopStockResult getStock(String productId, String skuId) throws WxErrorException;

48

}

49

50

public interface WxMaShopCatService {

51

// Product category management

52

List<WxMaShopCatInfo> getCatList() throws WxErrorException;

53

}

54

55

public interface WxMaShopImgService {

56

// Image upload and management

57

WxMaShopImgUploadResult uploadImg(File imgFile) throws WxErrorException;

58

WxMaShopImgUploadResult uploadImg(String imgUrl) throws WxErrorException;

59

}

60

```

61

62

### Order Management Services

63

64

Complete order lifecycle management from creation to fulfillment.

65

66

```java { .api }

67

public interface WxMaShopOrderService {

68

// Order Query Operations

69

WxMaShopOrderDetailResult getOrder(String orderId) throws WxErrorException;

70

WxMaShopOrderListResult getOrderList(WxMaShopOrderListRequest request) throws WxErrorException;

71

WxMaShopOrderListResult getOrderListByStatus(Integer status, Integer page, Integer pageSize) throws WxErrorException;

72

73

// Order Management

74

boolean changeOrderPrice(String orderId, String changeType, Long changeValue) throws WxErrorException;

75

boolean closeOrder(String orderId) throws WxErrorException;

76

boolean confirmOrder(String orderId) throws WxErrorException;

77

boolean cancelOrder(String orderId, String cancelReason) throws WxErrorException;

78

79

// Order Processing

80

boolean deliverOrder(String orderId, WxMaShopDeliveryInfo deliveryInfo) throws WxErrorException;

81

boolean confirmReceive(String orderId) throws WxErrorException;

82

83

// Certificates and Documentation

84

boolean uploadCertificates(String orderId, List<WxMaShopOrderCertificate> certificates) throws WxErrorException;

85

List<WxMaShopOrderCertificate> getCertificates(String orderId) throws WxErrorException;

86

87

// Order Statistics

88

WxMaShopOrderStatsResult getOrderStats(Date startDate, Date endDate) throws WxErrorException;

89

}

90

91

public interface WxMaShopAfterSaleService {

92

// After-sales and refund management

93

WxMaShopAfterSaleOrderResult getAfterSaleOrder(String afterSaleOrderId) throws WxErrorException;

94

boolean acceptAfterSale(String afterSaleOrderId, String addressId) throws WxErrorException;

95

boolean rejectAfterSale(String afterSaleOrderId, String rejectReason) throws WxErrorException;

96

boolean uploadReturnInfo(String afterSaleOrderId, WxMaShopReturnInfo returnInfo) throws WxErrorException;

97

}

98

```

99

100

### Payment Services

101

102

Payment processing and transaction management for mini program shop orders.

103

104

```java { .api }

105

public interface WxMaShopPayService {

106

// Payment operations

107

WxMaShopPayOrderResult createPayOrder(WxMaShopPayOrderRequest request) throws WxErrorException;

108

boolean notifyPayment(String orderId, String actionType, String transactionId) throws WxErrorException;

109

}

110

```

111

112

### Logistics and Delivery

113

114

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

115

116

```java { .api }

117

public interface WxMaShopDeliveryService {

118

// Logistics management

119

WxMaShopDeliveryListResult getDeliveryList() throws WxErrorException;

120

boolean sendDelivery(String orderId, String deliveryId, String waybillId) throws WxErrorException;

121

boolean recieveDelivery(String orderId) throws WxErrorException;

122

}

123

```

124

125

### Promotions and Coupons

126

127

Marketing tools including coupons, discounts, and promotional campaigns.

128

129

```java { .api }

130

public interface WxMaShopCouponService {

131

// Coupon management

132

String createCoupon(WxMaShopCouponInfo couponInfo) throws WxErrorException;

133

boolean updateCoupon(WxMaShopCouponInfo couponInfo) throws WxErrorException;

134

WxMaShopCouponInfo getCoupon(String couponId) throws WxErrorException;

135

WxMaShopCouponListResult getCouponList(Integer status, Integer page, Integer pageSize) throws WxErrorException;

136

boolean updateCouponStatus(String couponId, Integer status) throws WxErrorException;

137

}

138

```

139

140

### Affiliate and Sharing

141

142

Affiliate marketing and sharer management for social commerce.

143

144

```java { .api }

145

public interface WxMaShopSharerService {

146

// Affiliate/sharer management

147

boolean bindSharer(String openid, String sharerType) throws WxErrorException;

148

WxMaShopSharerInfo getSharer(String openid) throws WxErrorException;

149

WxMaShopSharerListResult getSharerList(Integer page, Integer pageSize) throws WxErrorException;

150

boolean unbindSharer(String openid) throws WxErrorException;

151

}

152

```

153

154

### Product Data Models

155

156

Comprehensive data models for product management and catalog operations.

157

158

```java { .api }

159

public class WxMaShopSpuInfo implements Serializable {

160

private String productId; // Product ID

161

private String title; // Product title

162

private String subTitle; // Subtitle

163

private String mainImgUrl; // Main image URL

164

private List<String> imgUrls; // Image URLs

165

private String detail; // Product description

166

private Integer brandId; // Brand ID

167

private List<Integer> catIds; // Category IDs

168

private List<WxMaShopSkuInfo> skus; // SKU information

169

private Map<String, Object> attrs; // Product attributes

170

private Integer status; // Status (0: not listed, 1: listed)

171

private Integer listing; // Listing status

172

private Long createTime; // Creation timestamp

173

private Long updateTime; // Update timestamp

174

175

// Getters and setters

176

public String getProductId();

177

public void setProductId(String productId);

178

public String getTitle();

179

public void setTitle(String title);

180

public String getSubTitle();

181

public void setSubTitle(String subTitle);

182

public String getMainImgUrl();

183

public void setMainImgUrl(String mainImgUrl);

184

public List<String> getImgUrls();

185

public void setImgUrls(List<String> imgUrls);

186

public List<WxMaShopSkuInfo> getSkus();

187

public void setSkus(List<WxMaShopSkuInfo> skus);

188

189

// Utility methods

190

public static WxMaShopSpuInfo fromJson(String json);

191

public String toJson();

192

}

193

194

public class WxMaShopSkuInfo implements Serializable {

195

private String skuId; // SKU ID

196

private String outSkuId; // External SKU ID

197

private String thumbImg; // Thumbnail image

198

private Integer salePrice; // Sale price (in cents)

199

private Integer marketPrice; // Market price (in cents)

200

private Integer stockNum; // Stock quantity

201

private String barcode; // Barcode

202

private String skuCode; // SKU code

203

private List<WxMaShopSkuAttr> skuAttrs; // SKU attributes

204

205

// Getters and setters

206

public String getSkuId();

207

public void setSkuId(String skuId);

208

public Integer getSalePrice();

209

public void setSalePrice(Integer salePrice);

210

public Integer getStockNum();

211

public void setStockNum(Integer stockNum);

212

public List<WxMaShopSkuAttr> getSkuAttrs();

213

public void setSkuAttrs(List<WxMaShopSkuAttr> skuAttrs);

214

}

215

216

public class WxMaShopSkuAttr {

217

private String attrKey; // Attribute key

218

private String attrValue; // Attribute value

219

220

public String getAttrKey();

221

public void setAttrKey(String attrKey);

222

public String getAttrValue();

223

public void setAttrValue(String attrValue);

224

}

225

```

226

227

### Order Data Models

228

229

Data models for order management and processing.

230

231

```java { .api }

232

public class WxMaShopOrderInfo implements Serializable {

233

private String orderId; // Order ID

234

private String openid; // User OpenID

235

private Integer orderStatus; // Order status

236

private Integer paymentMethod; // Payment method

237

private Integer totalPrice; // Total price (in cents)

238

private Integer freight; // Freight cost

239

private WxMaShopAddressInfo addressInfo; // Delivery address

240

private List<WxMaShopOrderItem> orderItems; // Order items

241

private Long createTime; // Creation time

242

private Long payTime; // Payment time

243

244

// Getters and setters

245

public String getOrderId();

246

public void setOrderId(String orderId);

247

public String getOpenid();

248

public void setOpenid(String openid);

249

public Integer getOrderStatus();

250

public void setOrderStatus(Integer orderStatus);

251

public Integer getTotalPrice();

252

public void setTotalPrice(Integer totalPrice);

253

public List<WxMaShopOrderItem> getOrderItems();

254

public void setOrderItems(List<WxMaShopOrderItem> orderItems);

255

}

256

257

public class WxMaShopOrderItem implements Serializable {

258

private String productId; // Product ID

259

private String skuId; // SKU ID

260

private String productTitle; // Product title

261

private String skuTitle; // SKU title

262

private Integer price; // Unit price

263

private Integer quantity; // Quantity

264

private String imgUrl; // Product image

265

266

// Getters and setters

267

public String getProductId();

268

public void setProductId(String productId);

269

public String getSkuId();

270

public void setSkuId(String skuId);

271

public Integer getPrice();

272

public void setPrice(Integer price);

273

public Integer getQuantity();

274

public void setQuantity(Integer quantity);

275

}

276

```

277

278

## Usage Examples

279

280

### Product Management

281

282

#### Add New Product (SPU)

283

284

```java

285

@Service

286

public class ProductService {

287

288

@Autowired

289

private WxMaService wxMaService;

290

291

public String addProduct(ProductCreateRequest request) {

292

try {

293

// Upload product images

294

List<String> imageUrls = new ArrayList<>();

295

for (File imageFile : request.getImageFiles()) {

296

WxMaShopImgUploadResult result = wxMaService.getShopImgService()

297

.uploadImg(imageFile);

298

imageUrls.add(result.getImgUrl());

299

}

300

301

// Create SPU

302

WxMaShopSpuInfo spuInfo = new WxMaShopSpuInfo();

303

spuInfo.setTitle(request.getTitle());

304

spuInfo.setSubTitle(request.getSubTitle());

305

spuInfo.setMainImgUrl(imageUrls.get(0));

306

spuInfo.setImgUrls(imageUrls);

307

spuInfo.setDetail(request.getDescription());

308

spuInfo.setBrandId(request.getBrandId());

309

spuInfo.setCatIds(request.getCategoryIds());

310

311

// Add SKUs

312

List<WxMaShopSkuInfo> skus = new ArrayList<>();

313

for (SkuCreateRequest skuRequest : request.getSkus()) {

314

WxMaShopSkuInfo sku = new WxMaShopSkuInfo();

315

sku.setOutSkuId(skuRequest.getExternalSkuId());

316

sku.setSalePrice(skuRequest.getSalePrice());

317

sku.setMarketPrice(skuRequest.getMarketPrice());

318

sku.setStockNum(skuRequest.getStockQuantity());

319

sku.setBarcode(skuRequest.getBarcode());

320

321

// Set SKU attributes (size, color, etc.)

322

List<WxMaShopSkuAttr> attrs = new ArrayList<>();

323

for (Map.Entry<String, String> attr : skuRequest.getAttributes().entrySet()) {

324

WxMaShopSkuAttr skuAttr = new WxMaShopSkuAttr();

325

skuAttr.setAttrKey(attr.getKey());

326

skuAttr.setAttrValue(attr.getValue());

327

attrs.add(skuAttr);

328

}

329

sku.setSkuAttrs(attrs);

330

331

skus.add(sku);

332

}

333

spuInfo.setSkus(skus);

334

335

// Add product to WeChat Shop

336

String productId = wxMaService.getShopSpuService().addSpu(spuInfo);

337

338

logger.info("Product added successfully: {}", productId);

339

return productId;

340

341

} catch (WxErrorException e) {

342

logger.error("Failed to add product: {}", e.getMessage());

343

throw new ProductCreationException("Failed to create product", e);

344

}

345

}

346

}

347

```

348

349

#### Update Product Information

350

351

```java

352

public void updateProduct(String productId, ProductUpdateRequest request) {

353

try {

354

// Get existing product

355

WxMaShopSpuInfo existingProduct = wxMaService.getShopSpuService()

356

.getSpu(productId);

357

358

// Update fields

359

if (request.getTitle() != null) {

360

existingProduct.setTitle(request.getTitle());

361

}

362

363

if (request.getSubTitle() != null) {

364

existingProduct.setSubTitle(request.getSubTitle());

365

}

366

367

if (request.getDescription() != null) {

368

existingProduct.setDetail(request.getDescription());

369

}

370

371

// Update images if provided

372

if (request.getNewImageFiles() != null && !request.getNewImageFiles().isEmpty()) {

373

List<String> newImageUrls = new ArrayList<>();

374

for (File imageFile : request.getNewImageFiles()) {

375

WxMaShopImgUploadResult result = wxMaService.getShopImgService()

376

.uploadImg(imageFile);

377

newImageUrls.add(result.getImgUrl());

378

}

379

existingProduct.setImgUrls(newImageUrls);

380

existingProduct.setMainImgUrl(newImageUrls.get(0));

381

}

382

383

// Update SKUs

384

if (request.getSkuUpdates() != null) {

385

List<WxMaShopSkuInfo> updatedSkus = new ArrayList<>();

386

for (WxMaShopSkuInfo existingSku : existingProduct.getSkus()) {

387

SkuUpdateRequest skuUpdate = request.getSkuUpdates().get(existingSku.getSkuId());

388

if (skuUpdate != null) {

389

if (skuUpdate.getSalePrice() != null) {

390

existingSku.setSalePrice(skuUpdate.getSalePrice());

391

}

392

if (skuUpdate.getStockQuantity() != null) {

393

existingSku.setStockNum(skuUpdate.getStockQuantity());

394

}

395

}

396

updatedSkus.add(existingSku);

397

}

398

existingProduct.setSkus(updatedSkus);

399

}

400

401

// Update in WeChat

402

boolean success = wxMaService.getShopSpuService().updateSpu(existingProduct);

403

404

if (success) {

405

logger.info("Product updated successfully: {}", productId);

406

}

407

408

} catch (WxErrorException e) {

409

logger.error("Failed to update product {}: {}", productId, e.getMessage());

410

throw new ProductUpdateException("Failed to update product", e);

411

}

412

}

413

```

414

415

#### Product Listing Management

416

417

```java

418

public void updateProductListing(String productId, boolean listed) {

419

try {

420

int listingStatus = listed ? 1 : 0;

421

422

boolean success = wxMaService.getShopSpuService()

423

.updateSpuListing(productId, listingStatus);

424

425

if (success) {

426

logger.info("Product {} listing status updated to: {}",

427

productId, listed ? "listed" : "unlisted");

428

}

429

430

} catch (WxErrorException e) {

431

logger.error("Failed to update listing for product {}: {}",

432

productId, e.getMessage());

433

}

434

}

435

436

public List<WxMaShopSpuInfo> getActiveProducts(int page, int pageSize) {

437

try {

438

WxMaShopSpuListResult result = wxMaService.getShopSpuService()

439

.getSpuList(1, page, pageSize); // Status 1 = listed

440

441

return result.getSpus();

442

443

} catch (WxErrorException e) {

444

logger.error("Failed to get active products: {}", e.getMessage());

445

return Collections.emptyList();

446

}

447

}

448

```

449

450

### Order Management

451

452

#### Order Processing Workflow

453

454

```java

455

@Service

456

public class OrderProcessingService {

457

458

public void processOrder(String orderId) {

459

try {

460

// Get order details

461

WxMaShopOrderDetailResult orderResult = wxMaService.getShopOrderService()

462

.getOrder(orderId);

463

464

WxMaShopOrderInfo order = orderResult.getOrder();

465

466

switch (order.getOrderStatus()) {

467

case 1: // Pending payment

468

handlePendingPayment(order);

469

break;

470

case 2: // Paid, pending fulfillment

471

handlePaidOrder(order);

472

break;

473

case 3: // Shipped

474

handleShippedOrder(order);

475

break;

476

case 4: // Completed

477

handleCompletedOrder(order);

478

break;

479

case 5: // Cancelled

480

handleCancelledOrder(order);

481

break;

482

}

483

484

} catch (WxErrorException e) {

485

logger.error("Failed to process order {}: {}", orderId, e.getMessage());

486

}

487

}

488

489

private void handlePaidOrder(WxMaShopOrderInfo order) {

490

try {

491

// Check inventory

492

boolean inventoryAvailable = checkInventory(order.getOrderItems());

493

494

if (!inventoryAvailable) {

495

// Close order due to insufficient inventory

496

wxMaService.getShopOrderService().closeOrder(order.getOrderId());

497

notificationService.notifyInventoryShortage(order);

498

return;

499

}

500

501

// Reserve inventory

502

inventoryService.reserveInventory(order.getOrderItems());

503

504

// Create fulfillment record

505

fulfillmentService.createFulfillment(order);

506

507

logger.info("Order {} processed for fulfillment", order.getOrderId());

508

509

} catch (Exception e) {

510

logger.error("Failed to handle paid order {}: {}",

511

order.getOrderId(), e.getMessage());

512

}

513

}

514

}

515

```

516

517

#### Order Query and Management

518

519

```java

520

@RestController

521

@RequestMapping("/api/orders")

522

public class OrderController {

523

524

@GetMapping

525

public ResponseEntity<PageResult<WxMaShopOrderInfo>> getOrders(

526

@RequestParam(defaultValue = "0") int page,

527

@RequestParam(defaultValue = "20") int pageSize,

528

@RequestParam(required = false) Integer status,

529

@RequestParam(required = false) String startTime,

530

@RequestParam(required = false) String endTime) {

531

532

try {

533

WxMaShopOrderListRequest request = new WxMaShopOrderListRequest();

534

request.setPage(page);

535

request.setPageSize(pageSize);

536

request.setStatus(status);

537

request.setStartTime(startTime);

538

request.setEndTime(endTime);

539

540

WxMaShopOrderListResult result = wxMaService.getShopOrderService()

541

.getOrderList(request);

542

543

PageResult<WxMaShopOrderInfo> pageResult = new PageResult<>();

544

pageResult.setItems(result.getOrderList());

545

pageResult.setTotalCount(result.getTotalNum());

546

pageResult.setPage(page);

547

pageResult.setPageSize(pageSize);

548

549

return ResponseEntity.ok(pageResult);

550

551

} catch (WxErrorException e) {

552

logger.error("Failed to get orders: {}", e.getMessage());

553

return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();

554

}

555

}

556

557

@PostMapping("/{orderId}/price")

558

public ResponseEntity<Void> changeOrderPrice(

559

@PathVariable String orderId,

560

@RequestBody PriceChangeRequest request) {

561

562

try {

563

boolean success = wxMaService.getShopOrderService().changeOrderPrice(

564

orderId,

565

request.getChangeType(), // "increase" or "decrease"

566

request.getChangeValue() // Amount in cents

567

);

568

569

if (success) {

570

return ResponseEntity.ok().build();

571

} else {

572

return ResponseEntity.badRequest().build();

573

}

574

575

} catch (WxErrorException e) {

576

logger.error("Failed to change order price: {}", e.getMessage());

577

return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();

578

}

579

}

580

}

581

```

582

583

### Payment Integration

584

585

#### Payment Order Creation

586

587

```java

588

@Service

589

public class PaymentService {

590

591

public WxMaShopPayOrderResult createPaymentOrder(PaymentOrderRequest request) {

592

try {

593

WxMaShopPayOrderRequest payOrderRequest = new WxMaShopPayOrderRequest();

594

payOrderRequest.setOrderId(request.getOrderId());

595

payOrderRequest.setOpenid(request.getOpenid());

596

payOrderRequest.setOutTradeNo(request.getOutTradeNo());

597

payOrderRequest.setTotalFee(request.getTotalFee());

598

payOrderRequest.setBody(request.getDescription());

599

payOrderRequest.setNotifyUrl(request.getNotifyUrl());

600

601

WxMaShopPayOrderResult result = wxMaService.getShopPayService()

602

.createPayOrder(payOrderRequest);

603

604

logger.info("Payment order created: {}", result.getPaymentParams());

605

return result;

606

607

} catch (WxErrorException e) {

608

logger.error("Failed to create payment order: {}", e.getMessage());

609

throw new PaymentException("Payment order creation failed", e);

610

}

611

}

612

613

@PostMapping("/payment/notify")

614

public ResponseEntity<String> handlePaymentNotification(

615

@RequestBody String notificationData,

616

HttpServletRequest request) {

617

618

try {

619

// Verify signature

620

String signature = request.getHeader("Wechatpay-Signature");

621

boolean signatureValid = verifySignature(notificationData, signature);

622

623

if (!signatureValid) {

624

return ResponseEntity.status(HttpStatus.UNAUTHORIZED)

625

.body("Invalid signature");

626

}

627

628

// Parse notification

629

PaymentNotification notification = parseNotification(notificationData);

630

631

// Notify WeChat of payment

632

wxMaService.getShopPayService().notifyPayment(

633

notification.getOrderId(),

634

"pay_success",

635

notification.getTransactionId()

636

);

637

638

// Process the paid order

639

orderProcessingService.processPaymentSuccess(notification);

640

641

return ResponseEntity.ok("SUCCESS");

642

643

} catch (Exception e) {

644

logger.error("Payment notification handling failed: {}", e.getMessage());

645

return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)

646

.body("Processing failed");

647

}

648

}

649

}

650

```

651

652

### Logistics Management

653

654

#### Shipping and Delivery

655

656

```java

657

@Service

658

public class LogisticsService {

659

660

public void shipOrder(String orderId, String deliveryCompanyId, String waybillId) {

661

try {

662

// Send delivery information

663

boolean success = wxMaService.getShopDeliveryService()

664

.sendDelivery(orderId, deliveryCompanyId, waybillId);

665

666

if (success) {

667

logger.info("Order {} shipped with waybill: {}", orderId, waybillId);

668

669

// Send shipping notification to user

670

notificationService.sendShippingNotification(orderId, waybillId);

671

}

672

673

} catch (WxErrorException e) {

674

logger.error("Failed to ship order {}: {}", orderId, e.getMessage());

675

}

676

}

677

678

public void confirmDelivery(String orderId) {

679

try {

680

boolean success = wxMaService.getShopDeliveryService()

681

.recieveDelivery(orderId);

682

683

if (success) {

684

logger.info("Delivery confirmed for order: {}", orderId);

685

686

// Process order completion

687

orderService.completeOrder(orderId);

688

}

689

690

} catch (WxErrorException e) {

691

logger.error("Failed to confirm delivery for order {}: {}",

692

orderId, e.getMessage());

693

}

694

}

695

696

public List<DeliveryCompany> getAvailableDeliveryCompanies() {

697

try {

698

WxMaShopDeliveryListResult result = wxMaService.getShopDeliveryService()

699

.getDeliveryList();

700

701

return result.getDeliveryList().stream()

702

.map(this::convertToDeliveryCompany)

703

.collect(Collectors.toList());

704

705

} catch (WxErrorException e) {

706

logger.error("Failed to get delivery companies: {}", e.getMessage());

707

return Collections.emptyList();

708

}

709

}

710

}

711

```

712

713

### After-Sales Management

714

715

```java

716

@Service

717

public class AfterSalesService {

718

719

public void processAfterSaleRequest(String afterSaleOrderId) {

720

try {

721

WxMaShopAfterSaleOrderResult result = wxMaService.getShopAfterSaleService()

722

.getAfterSaleOrder(afterSaleOrderId);

723

724

WxMaShopAfterSaleOrder afterSaleOrder = result.getAfterSaleOrder();

725

726

// Auto-approve for certain conditions

727

if (shouldAutoApprove(afterSaleOrder)) {

728

approveAfterSale(afterSaleOrderId);

729

} else {

730

// Manual review required

731

afterSaleReviewService.queueForReview(afterSaleOrder);

732

}

733

734

} catch (WxErrorException e) {

735

logger.error("Failed to process after-sale request {}: {}",

736

afterSaleOrderId, e.getMessage());

737

}

738

}

739

740

public void approveAfterSale(String afterSaleOrderId) {

741

try {

742

// Accept the after-sale request

743

boolean success = wxMaService.getShopAfterSaleService()

744

.acceptAfterSale(afterSaleOrderId, "default_address_id");

745

746

if (success) {

747

logger.info("After-sale request approved: {}", afterSaleOrderId);

748

749

// Send approval notification to customer

750

notificationService.sendAfterSaleApprovalNotification(afterSaleOrderId);

751

}

752

753

} catch (WxErrorException e) {

754

logger.error("Failed to approve after-sale {}: {}",

755

afterSaleOrderId, e.getMessage());

756

}

757

}

758

759

public void rejectAfterSale(String afterSaleOrderId, String reason) {

760

try {

761

boolean success = wxMaService.getShopAfterSaleService()

762

.rejectAfterSale(afterSaleOrderId, reason);

763

764

if (success) {

765

logger.info("After-sale request rejected: {} - Reason: {}",

766

afterSaleOrderId, reason);

767

}

768

769

} catch (WxErrorException e) {

770

logger.error("Failed to reject after-sale {}: {}",

771

afterSaleOrderId, e.getMessage());

772

}

773

}

774

}

775

```

776

777

### Coupon Management

778

779

```java

780

@Service

781

public class CouponService {

782

783

public String createDiscountCoupon(CouponCreateRequest request) {

784

try {

785

WxMaShopCouponInfo couponInfo = new WxMaShopCouponInfo();

786

couponInfo.setName(request.getName());

787

couponInfo.setType(request.getType()); // 1: discount, 2: cash

788

couponInfo.setDiscountCondition(request.getMinAmount());

789

couponInfo.setDiscountFee(request.getDiscountAmount());

790

couponInfo.setStartTime(request.getStartTime());

791

couponInfo.setEndTime(request.getEndTime());

792

couponInfo.setStockNum(request.getQuantity());

793

couponInfo.setReceiveNum(0);

794

795

String couponId = wxMaService.getShopCouponService()

796

.createCoupon(couponInfo);

797

798

logger.info("Coupon created: {} - {}", couponId, request.getName());

799

return couponId;

800

801

} catch (WxErrorException e) {

802

logger.error("Failed to create coupon: {}", e.getMessage());

803

throw new CouponCreationException("Coupon creation failed", e);

804

}

805

}

806

807

public void activateCoupon(String couponId) {

808

try {

809

boolean success = wxMaService.getShopCouponService()

810

.updateCouponStatus(couponId, 1); // 1 = active

811

812

if (success) {

813

logger.info("Coupon activated: {}", couponId);

814

}

815

816

} catch (WxErrorException e) {

817

logger.error("Failed to activate coupon {}: {}", couponId, e.getMessage());

818

}

819

}

820

}

821

```

822

823

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.